Reputation:
Can you give an example of how to use the get and set? I need to call the get method in my code but inorder to do that it needs to be set first by evaluating it everytime.
Ex:
private static string _formatStr = Product == "test" ? "something": "other";
public static string GetFormatStr
{
get { return _formatStr; }
}
So I need this to be set before I call the get method everytime. Call set first and then call get.
Upvotes: 0
Views: 720
Reputation: 10650
Please read the C# Language Specification or something.
Upvotes: 0
Reputation: 47978
public static string GetFormatStr
{
get { return Product == "test" ? "something": "other"; }
}
Upvotes: 0
Reputation: 56934
So, you mean that you want this :
public static string FormatStr
{
get
{
return Product == "test" ? "something" : "other";
}
}
Upvotes: 7