type-conversionmetadatatype

Datatype finding in C#


I have 10 data's in string array.In this 10 data, each of the data's could be integer/string/double/DateTime format. based on these 10 datatype we have to find common datatype.

Eg1: string["10","20","3","45"] -> o/p: int.

Eg2: string["10","2o","3","4","5.0","4","56"] -> o/p : float.

Eg3: string["10","20.5","ten","45"] -> o/p: string


Solution

  • Iterate : TryParse double, TryParse Int, TryParse DateTime, or string. Done.