adspace


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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

Which namespaces are necessary to create a localized application?

1142


How to assign Null value to Var?

1063


What is an abstract class c#?

969


How do you inherit a class into other class in c#?

993


What is expression tree in c#?

998


Why can't we use a static class instead of singleton?

954