What are properties in c#. Explain with an example?



What are properties in c#. Explain with an example?..

Answer / Ram Mohan

"Properties in C# provide a simpler and more object-oriented way to access private fields of a class. Properties can have getters (accessors) and setters (mutators). An example is as follows:nn public class Person {n private string name;n public string Name {n get { return name; }n set { name = value; }n }n }

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Sharp Interview Questions

How do you ensure the assembly created in c# is interoperable with vb.net?

4 Answers   IBM,


What is desktop application testing?

1 Answers  


An Array is a Ref Type? what about the array elements which are value type(int,Float...etc)?

6 Answers  


How do I get deterministic finalization in c#?

1 Answers  


What is a generic method?

1 Answers  


How to authenticate web service? When you enter the web service url in browser it should ask username and password. After entering the un&pwd we have to show its methods and service description(wsdl).

3 Answers  


Is overriding of a function possible in the same class?

1 Answers  


what are wrapper classes?

1 Answers  


If I want to override a method 1 of class A and in class b then how do you declare ?

4 Answers   MMTS,


How is lazy loading achieved?

1 Answers  


How is a loop recorder monitored?

1 Answers  


i need to insert data into sql server table emp through textboxes txtname and txtsalary using c# code. Please help

1 Answers  


Categories