- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- 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
UInt16.ToString Method in C# with Examples
The UInt16.ToString() method in C# is used to convert the numeric value of the current UInt16 instance to its equivalent string representation.
Syntax
Following is the syntax −
public override string ToString();
Example
Let us now see an example to implement the UInt16.ToString() method −
using System; public class Demo { public static void Main(){ ushort val1 = 100; ushort val2 = 80; Console.WriteLine("Value1 (String representation) = "+val1.ToString()); Console.WriteLine("Value2 (String representation) = "+val2.ToString()); bool res = val1.Equals(val2); Console.WriteLine("Return value (comparison) = "+res); if (res) Console.WriteLine("val1 = val2"); else Console.WriteLine("val1 != val2"); } }
Output
This will produce the following output −
Value1 (String representation) = 100 Value2 (String representation) = 80 Return value (comparison) = False val1 != val2
Example
Let us now see another example to implement the UInt16.ToString() method −
using System; public class Demo { public static void Main(){ ushort val1 = 0; ushort val2 = UInt16.MaxValue; Console.WriteLine("Value1 (String representation) = "+val1.ToString()); Console.WriteLine("Value2 (String representation) = "+val2.ToString()); bool res = val1.Equals(val2); Console.WriteLine("Return value (comparison) = "+res); if (res) Console.WriteLine("val1 = val2"); else Console.WriteLine("val1 != val2"); } }
Output
This will produce the following output −
Value1 (String representation) = 0 Value2 (String representation) = 65535 Return value (comparison) = False val1 != val2
Advertisements