Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Transformer is a C# library that helps you better interact with and transform data from one type into another.

License

NotificationsYou must be signed in to change notification settings

WilliamSmithEdward/Transformer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Convert from a string to an int

usingTransformer;string?myString="123";varmyInt=myString.ToNonNullableType<int>();Console.WriteLine(myInt);

Convert from a string to a date time

usingTransformer;string?myString="1/1/2023";varmyDateTime=myString.ToNonNullableType<DateTime>();Console.WriteLine(myDateTime);

Convert from a string to a nullable int

usingTransformer;string?myString="123A";varmyInt=myString.ToNullableType<int>();Console.WriteLine(myInt);// returns nullvarmyInt2=myString.ToNullableType<int>(false);Console.WriteLine(myInt2);// returns 0

Convert from an int to a float

usingTransformer;varmyInt=1;varmyFloat=myInt.ToNonNullableType<float>();Console.WriteLine(myFloat);

Test if string is parseable to an int

usingTransformer;string?myString="123A";Console.WriteLine(myString.IsParseable<int>());// returns falsestring?myNullString=null;Console.WriteLine(myNullString.IsParseable<int>());// returns falseConsole.WriteLine(myNullString.IsParseable<int>(allowNullable:true));// returns true

Transform one ICollection to another

varlist=newList<string>(){"1","bob","apple","2","3","4","5"};vartransformedList=list.ToNonNullableCollectionType<List<string>,string,List<int>,int>();foreach(varitemintransformedList.TransformationSuccesses){Console.WriteLine(item);}Console.WriteLine();foreach(varitemintransformedList.TransformationFailures){Console.WriteLine(item);}

About

Transformer is a C# library that helps you better interact with and transform data from one type into another.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors2

  •  
  •  

Languages


[8]ページ先頭

©2009-2025 Movatter.jp