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

Explain about .net assemblies?

1090


Compare client server application with n-tier application

979


what is dotnet architecture? can anyone explain that.

4486


What is WSDL? Explain its architecture?

1262


Explain what is mutex?

1126


Difference between abstract class and interface in .net?

1166


How many namespaces are in .net version 1.1?

1195


What is typical about a windows process in regards to memory allocation in .net?

1082


How can you turn-on and turn-off cas?

1036


Explain what are the deferred execution and the immediate execution in linq?

1101


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

1215


What is the difference between encrypting a password and applying a hashing?

1198


Is .net core the future?

1057


Explain how com+ related to the dna architecture?

1065


Explain about the features and elements present in Visual studio.NET IDE?

1116