Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • C# Data Types
  • C# Decision Making
  • C# Methods
  • C# Delegates
  • C# Constructors
  • C# Arrays
  • C# ArrayList
  • C# String
  • C# Tuple
  • C# Indexers
  • C# Interface
  • C# Multithreading
  • C# Exception
Open In App
Next Article:
UInt32.ToString Method in C# with Examples | Set - 2
Next article icon

SByte.ToString Method in C# with Examples | Set – 2

Last Updated : 01 May, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report

SByte.ToString Method is used to convert the numeric value of the current instance to its equivalent string representation. There are 4 methods in the overload list of this method as follows:

  1. ToString(IFormatProvider) Method
  2. ToString(String, IFormatProvider) Method
  3. ToString() Method
  4. ToString(String) Method

Here, we will discuss the last two methods.

ToString() Method

This method is used to convert the numeric value of the current instance to its equivalent string representation.

Syntax:

public override string ToString ();

Return Value: This method returns the string representation of the value of the current instance, consisting of a minus sign if the value is negative, and a sequence of digits ranging from 0 to 9 with no leading zeroes.

Example:




// C# program to illustrate the
// SByte.ToString() Method
using System;
using System.Globalization;
  
class GFG {
  
    // Main Method
    public static void Main()
    {
  
        Console.WriteLine("The String values are: ");
  
        // calling the method
        result(SByte.MaxValue);
        result(SByte.MinValue);
        result(120);
        result(86);
    }
  
    // result() method
    public static void result(sbyte p)
    {
  
        // using ToString() method
        string str = p.ToString();
  
        // Display the value
        Console.WriteLine("The Corresponding String "
                              + "Value is: {0}",str);
                            
    }
}
 
 
Output:
  The String values are:   The Corresponding String Value is: 127  The Corresponding String Value is: -128  The Corresponding String Value is: 120  The Corresponding String Value is: 86  

ToString(String) Method

This method is used to convert the numeric value of the current instance to its equivalent string representation, using the specified format.

Syntax:

public string ToString (string format);

Parameters: This method takes standard or custom numeric format string.

Return Value: This method returns the string representation of the value of this instance as specified by format.

Example:




// C# program to demonstrate the
// SByte.ToString(String) Method
using System;
  
class GFG {
  
    // Main Method
    public static void Main()
    {
        try {
  
            // Declaring and initializing value
            sbyte val = 114;
  
            // Declaring and initializing format
            string format = "E2";
  
            // using the method
            string result = val.ToString(format);
  
            // Display the result
            Console.WriteLine("The value of string is {0}", result);
        }
  
        catch (FormatException e) 
        {
            Console.WriteLine("Format is invalid.");
            Console.Write("Exception Thrown: ");
            Console.Write("{0}", e.GetType(), e.Message);
        }
    }
}
 
 
Output:
  The value of string is 1.14E+002  

Reference:

  • https://docs.microsoft.com/en-us/dotnet/api/system.sbyte.tostring?view=netcore-2.1


Next Article
UInt32.ToString Method in C# with Examples | Set - 2

K

Kirti_Mangal
Improve
Article Tags :
  • C#
  • CSharp-method
  • CSharp-SByte-Struct

Similar Reads

  • SByte.ToString() Method in C# with Examples | Set - 1
    SByte.ToString Method is used to convert the numeric value of the current SByte instance to its equivalent string representation. There are 4 methods in the overload list of this method as follows: ToString(IFormatProvider) Method ToString(String, IFormatProvider) Method ToString() Method ToString(S
    2 min read
  • UInt32.ToString Method in C# with Examples | Set - 2
    UInt32.ToString Method is used to convert the numeric value of the current instance to its equivalent string representation. There are 4 methods in the overload list of this method as follows: ToString(IFormatProvider) Method ToString(String, IFormatProvider) Method ToString() Method ToString(String
    2 min read
  • UInt64.ToString Method in C# with Examples | Set - 2
    UInt64.ToString Method is used to convert the numeric value of the current instance to its equivalent string representation. There are 4 methods in the overload list of this method as follows: ToString(IFormatProvider) Method ToString(String, IFormatProvider) Method ToString() Method ToString(String
    2 min read
  • UInt16.ToString Method in C# with Examples | Set - 2
    UInt16.ToString Method is used to convert the numeric value of the current instance to its equivalent string representation. There are 4 methods in the overload list of this method as follows: ToString(IFormatProvider) Method ToString(String, IFormatProvider) Method ToString() Method ToString(String
    2 min read
  • Stack.ToString() Method in C# with examples
    ToString method is inherited from the Object class which is used to get a string that represents the current object. It can also apply on the Stack. It returns a string which represents the current stack object. Syntax: public virtual string ToString (); Return Value: This method returns a String re
    2 min read
  • UInt32.ToString() Method in C# with Examples | Set - 1
    UInt32.ToString Method is used to convert the numeric value of the current UInt32 instance to its equivalent string representation. There are 4 methods in the overload list of this method as follows: ToString(IFormatProvider) Method ToString(String, IFormatProvider) Method ToString() Method ToString
    3 min read
  • UInt64.ToString() Method in C# with Examples | Set - 1
    UInt64.ToString Method is used to convert the numeric value of the current UInt64 instance to its equivalent string representation. There are 4 methods in the overload list of this method as follows: ToString(IFormatProvider) Method ToString(String, IFormatProvider) Method ToString() Method ToString
    3 min read
  • UInt16.ToString() Method in C# with Examples | Set - 1
    UInt16.ToString Method is used to convert the numeric value of the current UInt16 instance to its equivalent string representation. There are 4 methods in the overload list of this method as follows: ToString(IFormatProvider) Method ToString(String, IFormatProvider) Method ToString() Method ToString
    3 min read
  • SByte.CompareTo() Method in C# with Examples
    SByte.CompareTo() Method is used to compare the current instance to a specified object or SByte and returns an indication of their relative values. There are 2 methods in the overload list of this method as follows: CompareTo(SByte) Method CompareTo(Object) Method SByte.CompareTo(SByte) Method This
    4 min read
  • SByte.Equals Method in C# with Examples
    SByte.Equals Method is used to get a value which indicates whether the current instance is equal to a specified object or SByte or not. There are 2 methods in the overload list of this method as follows: Equals(SByte) Method Equals(Object) Method SByte.Equals(SByte) Method This method is used to ret
    3 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences