.Net · C#

New Class in .Net 4.1

Came across a new class in framework .Net 4.1 StringOr<TOther>

public class StringOr<TOther> {
public StringOr(string stringValue, TOther otherValue);

public string StringValue { get; }
public TOther OtherValue { get; }
}

There are lot of situations where you store datetime and other values in string simply because they are not formatted correctly or there are chances that database may or may not return a value which can be converted to exact format.

StringOr<int> userInput= GetUserInput(“Quantity”);
string szUserInput=userInput.StringValue;
int intUserInput=userInput.OtherValue;

Here is the solution to that problem.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s