Wednesday, April 1, 2009

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.

No comments:

Post a Comment