Skip to content

Instantly share code, notes, and snippets.

@arttuladhar
Created January 13, 2012 16:33
Show Gist options
  • Save arttuladhar/1607364 to your computer and use it in GitHub Desktop.
Save arttuladhar/1607364 to your computer and use it in GitHub Desktop.
This way of instanciating a class is totally valid in C# 3.0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication3
{
class Program
{
public class Person{
private string _firstName;
private string _lastname;
public Person() {}
public string Firstname {
get{
return _firstName;
}
set
{
_firstName = value;
}
}
public string Lastname
{
get
{
return _lastname;
}
set
{
_lastname = value;
}
}
}
static void Main(string[] args)
{
Person p1 = new Person
{
Firstname = "Jyoti",
Lastname = "Tuladhar"
};
Console.WriteLine(p1.Firstname.ToString());
Console.ReadLine();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment