Skip to content

Latest commit

 

History

History
25 lines (18 loc) · 567 Bytes

File metadata and controls

25 lines (18 loc) · 567 Bytes

GCop 121

"Use numericString.To<DataType>() instead of DataType.Parse(numericString)"

Rule description

The To<...>() extension method on the string type allows you to make type conversions in a uniform way for many types. It's also briefer and more readable. Just like you can say myInt.ToString(), you can say myString.To<int>().

Example

public long Foo(string commission)
{
    return long.Parse(commission);
}

should be 🡻

public string Foo(string commission)
{
    return commision.To<long>();
}