Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
Testing for Integers and Floats in a String
//Title of this code //Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { // testing for integers in a string string myString = "230"; double myInt; bool isNumeric = double.TryParse(myString, out myInt); Console.WriteLine(isNumeric); Console.WriteLine(myInt+"\n"); // trying with a zero-padded string myString = "00425"; isNumeric = double.TryParse(myString, out myInt); Console.WriteLine(isNumeric); Console.WriteLine(myInt+"\n"); myString = "0000535.2431"; float myFloat; isNumeric = float.TryParse(myString, out myFloat); Console.WriteLine(isNumeric); Console.WriteLine(myFloat+"\n"); } } }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Square Integer Matrix
AdventCode
hackes
Accessit SalaryCalculation
ok
Des encryption
extrefGenerate
Ejemplos polimorfismos con interfaces y posibles usos sencillos c#
asfdfsafasfsa
Task List
Please log in to post a comment.