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

What is the difference between override and overload in a method?

1209


What is static constructor, when it will be fired?

1063


What is the difference between response.redirect & server.transfer?

1150


How do you view the methods and members of a dll?

1134


Explain how do assemblies find each other?

1085


which methos do you invoke on the dataadapter control to load your generated dataset with data?

1070


What is the use of design pattern?

1024


Is there built-in support for tracing?

1037


What is multiThreading in .NET?

1059


Please explain what do the terms “boxing” and “unboxing” mean?

1023


Explain the different parts of an assembly?

1046


Why do we use msmq?

1010


Do you know the difference between the stack and the heap?

1005


What is the difference between imperative and interrogative code?

2066


What is msil, il?

1076