开发者

utility class in to serve different TabItems

I'm new to C# and I'm trying to find out whats the way to write a utility class that could serve, in my case, 开发者_开发技巧a few different tabitems. In JAVA I could write an Enum class for that purpose. How do you do that in C#?


It's difficult to tell what exactly the question is, but if you are looking to declare an enumeration, C# has the enum keyword (see: MSDN). E.g.:

enum Days {Sat, Sun, Mon, Tue, Wed, Thu, Fri};

You can then use the enum directly:

public void PrintDayName(Days day)
{
   //...
}

Regarding your comment:

I want to build a class that will provide access to methods for a few different classes. All the class will need access to the same instance of this "utility" class.

If you refer to the enum as above, it will effectively be the "same instance", since each enum value simply represents some integral value (e.g. 0, 1, 2, 3, etc). If you are referring to an actual utility class, those are typically implemented as static classes, which works pretty similarly to how Java treats the static keyword.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜