Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
C# .ToInt() Extension Method Example
using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using Extensions; // Calling extension method .ToInt() will convert a string to Int or throw the exception "Input string was not in a correct format." // This works for internal variables and also Console.ReadLine(); namespace Rextester { public class Program { public static void Main(string[] args) { Console.WriteLine("32".ToInt() + "55".ToInt()); //Console.WriteLine(Console.ReadLine().ToInt() + Console.ReadLine().ToInt()); } } } namespace Extensions { public static class StringExtensions { public static int ToInt(this string s) { int returnInt = 0; try { returnInt = Int32.Parse(s); } catch(Exception ex) { throw ex; } return returnInt; } } }
run
|
edit
|
history
|
help
2
kod 1
u
Hex-String Encoder/Decoder + Obfuscator by Cuppujeano
Write a program to count the occurrence of each distinct item in the array?
sulu
My First Hello world
Array Alternate elements
D19
lj
HelloWorld