- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are binary literals and digit separators in C# 7.0?
Binary Literals −
Before C# 7 we were able to assign only decimal and hexadecimal values to a variable.
In C# 7.0 binary literal has been introduced and it allows us binary value to the variable.
Digit Separator −
Digit Separator takes the form of a single underscore (_). This separator can be used within any numeric literal as a means of improving legibility.
Example Binary Literals −
Example
class Program{ public static void Main(){ var bn = 0b1000001; System.Console.WriteLine(bn.GetType()); System.Console.WriteLine(Convert.ToChar(bn)); Console.ReadLine(); } }
Output
System.Int32 A
Example Digit Seperator −
Example
class Program{ public static void Main(){ long Salary = 1_00_00_00_00_000; System.Console.WriteLine(Salary.GetType()); System.Console.WriteLine(Salary); Console.ReadLine(); } }
Output
System.Int64 100000000000
- Related Articles
- What are Deconstructors in C# 7.0?
- What are Local functions in C# 7.0?
- What are Ref locals and Ref returns in C# 7.0?
- What are literals in C++?
- What are string literals in C#?
- What are integer literals in C#?
- What are Boolean Literals in C++?
- What are Character Literals in C++?
- What are the improvements in Out Parameter in C# 7.0?
- What are floating point literals in C#?
- What are string literals in C language?
- What is Pattern Matching in C# 7.0?
- What are literals in Java?
- What are Literals in Python?
- What are JSP literals?

Advertisements