answersLogoWhite

0

How do you reverse the number using c sharp?

Updated: 8/17/2019
User Avatar

Wiki User

13y ago

Best Answer

The following codes only applied to unsigned integers:

public int Reverse(int inputNumber) {

string inputString = inputNumber.ToString();

string reversed = StringUtil.Reverse(inputString);

return int.Parse(reversed);

}

public class StringUtil {

// returns a reversed string from the given one

public static string Reserve(string originalString) {

StringBuilder sb = new StringBuilder();

char[] charArray = originalString.ToCharArray();

for (int i = charArray.Length - 1; i >= 0; i--) {

sb.Append(charArray[i]);

}

return sb.ToString();

}

}

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you reverse the number using c sharp?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you know that a numeric is palindrome or not using c or pascal language?

Reverse the digits then check of the new number is the same as the original number.


What are the notes for the c sharp harmonic scale?

C sharp, D sharp, E natural, F sharp, G sharp, A natural, B sharp & C sharp We call the note C "B sharp" to avoid using the same letter name twice. If we used the note name "C" we would have 2 C-notes and no B-notes in the scale!


How do you convert a number that consist of alphabet and number in reverse order?

To reverse a number, first convert the number to a string, then reverse the string. Given your number consists of alphanumeric characters, the number must already be a string so simply reverse the string: #include<string> using std::string; string reverse (const string& s) { string str {}; for (auto c : s) str.insert (str.begin(), c); return str; } int main () { std::cout << "Enter a number: "; string s {}; std::cin >> s; std::cout << "The number in reverse is: " << reverse (s); }


How do you Write a C program to reverse an Integer number.?

Reference:cprogramming-bd.com/c_page2.aspx# reverse number


What about multithreading in c sharp?

Multi-threading in c sharp is a system with different tutorial. Like: interaction between threads, producer, using thread pool and using mutex objects.


Count characters in an input string using c sharp?

Console.WriteLine("Please input a string:"); string str = Console.ReadLine(); Console.WriteLine("Number of characters: " + str.Length);


What are the notes to?

A sharp G G E sharp G E sharp A sharp A sharp C C A sharp C E sharp G A G E sharp A sharp A sharp A sharp G E sharp C this is not on the Flute btw idk what instrument its on


What are the notes to fireflies?

A sharp G G E sharp G E sharp A sharp A sharp C C A sharp C E sharp G A G E sharp A sharp A sharp A sharp G E sharp C this is not on the flute btw idk what instrument its on


How do you play Simpson theme on keyboard?

here it is C,E,F SHARP,A,G,E,C,A,F SHARP,F SHARP,F SHARP,G,A SHARP,C,C,C,C


How do you work out the notes in the scale of c sharp using the circle of fifths?

Take the C Maj scale and sharp everything. C# D# E# F# G# A# B# C# I ii iii IV V vi vii* I


What key signature has G sharp B sharp and C sharp?

C# Major


How you write a program in c plus plus to print plaindromic numbers from 1 to n?

To check if a number is a palindrome, reverse the number and see if it is equal to the original number. If so, the number is a palindrome, otherwise it is not. To reverse a number, use the following function: int reverse(int num, int base=10) { int reverse=0; while( num ) { reverse*=base; reverse+=num%base; num/=base; } return(reverse); }