UPDATE: Sorry, I was wrong, StringBar is returned. Let's see if I can work out how to delete this question.
Imagine the following class:
public class Foo
{
public int Bar { get; set; }
public string StringBar
{
get { return Bar.ToString(); }
}
public void DoSomething()
{
}
}
If I write: typeof(Foo).GetProperties()
, the StringBar property info is not returned, I presume because C# thinks of it as a method, not a property.
From a programmers perspective though, there is a difference: a method would usually be expected to cause some state change, whereas a property wouldn't.
What is the best way to get the Bar and StringBar properties, but not the DoSomething method (without specifically referring to their names obviously)?