473,386 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Make a program that associates all 26 English alphabets A-Z with the index 1-26. User

Make a program that associates all 26 English alphabets A-Z with the index 1-26. User will enter a number from 1 to 26 and it will show the associated alphabet.
Mar 21 '19 #1
2 2594
gits
5,390 Expert Mod 4TB
well - never used c# but found a online fiddle to fiddle around with c# :) the basic idea could look like something like this:

Expand|Select|Wrap|Line Numbers
  1. using System;
  2.  
  3. public class Program
  4. {
  5.     public static void Main()
  6.     {    
  7.         char [] alpha = {'a', 'b', 'c', 'd'};
  8.  
  9.         string txt = Console.ReadLine();
  10.  
  11.         Console.WriteLine(
  12.             alpha[Convert.ToInt32(txt)]
  13.         );
  14.     }
  15. }
note that it needs adaption to your real case - and probably correct error handling and so forth. the idea is just to use an array with the elements you want to retrieve. now the input should be an integer between 0 and the array's length which then directly can be used to acces the corresponding element in the array.
Mar 22 '19 #2
SioSio
272 256MB
In the following example,
Enter a numerical value in textBox1 and press button1, the alphabet will be displayed in textbBx2.
Expand|Select|Wrap|Line Numbers
  1.         void Button1Click(object sender, EventArgs e)
  2.         {
  3.             textBox2.Text = Convert.ToChar(int.Parse(textBox1.Text) + 0x40) + "";
  4.         }
  5.  
Jan 10 '20 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: dwelch91 | last post by:
Greetings- This is on Linux... I have a daemon running as root and I want to execute another Python program as another user (a regular user). I have the name of the user and can use the 'pwd' and...
6
by: Nicky | last post by:
hi,all We are going to develop a program and when it is running, we need it full screen and also, user can not switch to other place before exit our program. I am thinking, we can make a window...
0
by: Nicky | last post by:
hi,all We are going to develop a program and when it is running, we need it full screen and also, user can not switch to other place before exit our program. I am thinking, we can make a window...
5
by: scorpion53061 | last post by:
Is there a way that anyone knows to force a vb.net program to shut down and then restart itself?
4
by: Owen Jenkins | last post by:
Hi, No-one replied to this when I sent it last week. Any bites out there today?? ----- My application allows users to create a new back end for separate purposes. It does this by using Make...
1
by: Anh Khuong | last post by:
Hi all, In some cases I click button to open dialog using ShowDialog(this) method, it make program freeze. Can you show me which cases this method cause problem above? Here are stack dump...
2
by: Bisyar khub | last post by:
hello,...i want to make program to square the numbers from 1 to 20. i have written this program, it's running but not giving the required answer.i think it is giving a garbage value...please tell me...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.