Class with one field, one constructor - CSharp Custom Type

CSharp examples for Custom Type:class

Description

Class with one field, one constructor

Demo Code

using System;//from  www. j a va2s .c o m
public class Dog {
   private string Name;
   public Dog( string name ) {
      Name = name;
   }
   public void Speak( ) {
      Console.WriteLine( "Hello. My name is {0}", Name );
   }
}
public class Simple {
   public static void Main( ) {
      Dog spot = new Dog( "spot" );
      spot.Speak( );
   }
}

Result


Related Tutorials