Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How is a property designated as read-only?

Answer Posted / om nama shivaya

Properties can be made read-only.Read only property means
the property value can not be changed . values for read
only property can be assigned through object creation.

using System;

public class Customer
{
private int m_id = -1;
private string m_name = string.Empty;

public Customer(int id, string name)
{
m_id = id;
m_name = name;
}

public int ID
{
get
{
return m_id;
}
}

public string Name
{
get
{
return m_name;
}
}
}

public class ReadOnlyCustomerManager
{
public static void Main()
{
Customer cust = new Customer(1, "Amelio Rosales");

Console.WriteLine(
"ID: {0}, Name: {1}",
cust.ID,
cust.Name);

Console.ReadKey();
}
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can I write my own .net host?

1047


object is physical and class is logical..here class is not occupying any memory as our definition of class but i got a question then the class where it stores if it is not occupying any memory....

2043


What is .net3.5?

983


What is the use of gacutil.exe?

1173


Explain attributes in dot net?

988


What is lambda expressions in c#?

1068


What is managed code and managed data in .net?

1005


How do you turn off cookies for one page in your site? Give an example.

895


What data providers available in .net to connect to database?

922


How does u handle this COM components developed in other programming languages in .NET?

2068


What is interface and abstract class in .net?

975


Explain boxing and unboxing in .net.

947


When displaying fonts, what is the difference between pixels, points and ems?

1123


What is delegation in .net?

1025


What is the difference between task and thread in .net?

1024