Here is a simple example.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
MyClass myclass1 = new MyClass(); // calls the constror with no parameters
string value = "abc";
MyClass myclass2 = new MyClass(value); // calls the constror with one parameters
}
public class MyClass()
{
public MyClass()
{
//this is the consructor with no paraameters
//it has the same name as the class an no return or void
}
public MyClass(string value)
{
//this is the consructor with one paraameters
//it has the same name as the class an no return or void
}
}
}
}
jdweng
No comments:
Post a Comment