Classes: Difference between revisions

Content deleted Content added
m →‎{{header|Ruby}}: show a class method
Line 318: Line 318:
};</lang>
};</lang>


=={{header|C sharp|C #}}==
=={{header|C sharp|C#}}==
<lang csharp>public class MyClass

{
public class MyClass
{
public MyClass()
public MyClass()
{
{
Line 331: Line 330:
public int Variable
public int Variable
{
{
get { return _variable; }
get { return _variable; }
set { _variable = value; }
set { _variable = value; }
}
}
public static void Main()
public static void Main()
{
{
// instantiate it
// instantiate it
MyClass instance = new MyClass();
MyClass instance = new MyClass();
// invoke the method
// invoke the method
instance.SomeMethod();
instance.SomeMethod();
// set the variable
// set the variable
instance.Variable = 99;
instance.Variable = 99;
// get the variable
// get the variable
System.Console.WriteLine( "Variable=" + instance.Variable.ToString() );
System.Console.WriteLine( "Variable=" + instance.Variable.ToString() );
}
}
}</lang>
}


=={{header|Common Lisp}}==
=={{header|Common Lisp}}==