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's typical about a windows process in regards to memory allocation in .net?

1101


What is .net environment?

1085


What's singleton activation mode in .net?

1061


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

964


What does cil do?

993


What is .net code security?

997


What is file extension of Webservices in .Net?

1063


Please explain what are an inheritance, polymorphism, and encapsulation?

1082


What is the difference between a namespace and assembly name in .net?

978


What does mean by .net framework?

1130


What is an anonymous method and how is it different from a lambda expression?

989


Which namespace is require to used XML in .NET?

1012


Please explain what is heap and what is stack?

995


Explain what is the difference between web application and enterprise application?

1032


What is the transport protocol you use to call a seb service soap?

979