How to separate groups of digits in numeric literals with underscore in C#

4 Answers

0 votes
using System;

public class Program
{
	public static void Main(string[] args)
	{
		long creditCardNumber = 1234_5678_9101_1129L;
		
		Console.WriteLine("Credit Card Number: " + creditCardNumber);
	}
}



/*
run:
  
Credit Card Number: 1234567891011129
  
*/

 



answered Aug 1, 2022 by avibootz
0 votes
using System;

public class Program
{
	public static void Main(string[] args)
	{
		float pi =  3.14_15_92F;
         
        Console.WriteLine("PI: " + pi);
	}
}



/*
run:
  
PI: 3.141592
  
*/

 



answered Aug 1, 2022 by avibootz
0 votes
using System;

public class Program
{
	public static void Main(string[] args)
	{
		long hexLong = 0x5F_3A_DE_BD;
         
        Console.WriteLine("Hex long: " + hexLong);
	}
}



/*
run:
  
Hex long: 1597693629
  
*/

 



answered Aug 1, 2022 by avibootz
0 votes
using System;

public class Program
{
	public static void Main(string[] args)
	{
		byte binByte = 0b0010_0111;
         
        Console.WriteLine("binByte: " + binByte);
	}
}



/*
run:
  
binByte: 39
  
*/

 



answered Aug 1, 2022 by avibootz

Related questions

1 answer 186 views
1 answer 186 views
1 answer 233 views
1 answer 198 views
1 answer 111 views
2 answers 233 views
233 views asked Feb 26, 2015 by avibootz
...