Top "Tryparse" questions

Converts the string representation of an object to its typed equivalent.

int.TryParse() returns false for "#.##"

I'm having a function which receives string parameters and convert them to integers. For safe conversion int.TryParse() is used. …

c# tryparse
DateTime.TryParse converts decimal to datetime

The following line of code return true (which it should not)....and convert 1.0228 into datetime... DateTime.TryParse(1.0228,out temporaryDateTimeValue) Somebody …

c# datetime tryparse
Empty String to Double using (Try)Parse

I've got a with 1.1 build system here using Parse for converting values (now it's 3.5). string myString = String.Empty; double myValue = …

c# parsing double tryparse
Is this value a valid year C#

What's the best way to check if a string is a valid year using C#? I currently have a dropdown …

c# datetime tryparse
DateTime.TryParse century control C#

The result of the following snippet is "12/06/1930 12:00:00". How do I control the implied century so that "12 Jun 30" becomes 2030 instead? string …

c# datetime tryparse
TryParse to a nullable type

I would like to try to parse a string as a DateTime?, and if it fails then set the value …

c# .net null nullable tryparse
Enum.TryParse returns true for any numeric values

I'm running into a behavior I wasn't expecting when using Enum.TryParse. If I have an enum: public enum MyEnum { …

c# validation enums tryparse
How to use double.TryParse when the output is allowed to be null?

In my application I have a textbox - txtDiscount where the admin can set a discount percentage for a certain …

c# nullable tryparse
TryParse create inline parameter?

Is there any way in C# to create a variable inline? Something like this: int x = int.TryParse("5", out new …

c# .net type-conversion clr tryparse
IPAddress.TryParse returns false

I have a string with IP Address which is clientId = "172.19.200.29:10308" I need to generate IPAddress object from it.Tried the …

c# ip-address tryparse