Forum Settings
       
Reply To Thread

Excuse me kind Sirs and Ladies, I have a C# program questionFollow

#1 Sep 03 2006 at 1:24 AM Rating: Decent
**
261 posts
Hey ya'll

I'm trying to make an ASCII converter program for school and it needs to have 3 different methods. Don't laugh but here's my newb program:




using System;
using System.Collections.Generic;
using System.Text;

namespace ASCIIWeek4
{
public class Crypto
{
string input;
string value;
string symbol;
public string getInput()
{
int input;

Console.WriteLine("Enter a character: >");
input = Console.Read();
return input;
}

public char convert(string input)
{

int value;

value = Convert.Parse(symbol);
}

public void displayMessage(char letter)
{

Console.WriteLine("The AscII value of your character: " + (char) value + "is" + value);
}
public static void Main(String[] args)
{
return;
}
}
}




I asked my teacher for help and he responded:


"Comments:
Hi, not to worry, I understand. So the problems here are that you have to return the values you read in. For example in the getInput, you're reading into "input" but you're returning "symbol". Also, all of those variables shouldn't be declared globally. You should only declare the variables you need in the methods locally. The convert method, should just be a char.Parse(symbol) and return a char value (as you see in the return value). Then lastly, in the main method, you should have what was shown before in the sample program, but commented out and then changed to your method of naming."



I understand what he's saying (mostly), but I don't know what to change ; ;




I keep getting 3 errors when i debug they are:



Error 1 Cannot implicitly convert type 'int' to 'string' C:\Documents and Settings\USER\My Documents\Unzipped\ASCIIWeek4\ASCIIWeek4\ASCIIWeek4\Program.cs Line:18 Column:20 ASCIIWeek4


Error 2 'System.Convert' does not contain a definition for 'Parse' C:\Documents and Settings\USER\My Documents\Unzipped\ASCIIWeek4\ASCIIWeek4\ASCIIWeek4\Program.cs L:26 C:29 ASCIIWeek4


Error 3 Cannot convert type 'string' to 'char' C:\Documents and Settings\USER\My Documents\Unzipped\ASCIIWeek4\ASCIIWeek4\ASCIIWeek4\Program.cs L:32 C:67 ASCIIWeek4





I am using microsoft visual C# express 2005.
Can anyone tell me what I am doing wrong here and tell me how to correct it. My stress headache is KILLINE ME! lol

Thanks in advance
clueless ~B
#2 Sep 03 2006 at 1:36 AM Rating: Default
You would probably get more help on a forum specifically for help with C#. I don't know how to program in C#, so I'm not much help. :\
#3 Sep 03 2006 at 1:41 AM Rating: Decent
**
261 posts
Thank you for responding ^^
I actually have posted this thread in a few forums. I am finding it difficult to get help because it is such a basic program. No one responds, and the ones that do respond are little help, only telling me how wrong it is without offering any assistance ; ;

#4 Sep 03 2006 at 2:15 AM Rating: Good
Couple of things.

Console.Read() returns a string I think, so if you are trying to conver that to int (input), you can't convert it implicitly. Try input = int.parse(Console.Read());

This is really late for me and I'm slightly drunk, I'll try plugging your code in tomorrow and see what I can come up with. I'm not familiar with Convert.Parse, and I forget the exact syntax to use Char but I don't think you have it right. Try searching google for the exact error message:

Cannot convert type 'string' to 'char'

Sometimes you come across someone who has asked a similar question. Also, the MSDN can be very helpful.

I'll look at it tomorrow morning if you haven't found an answer yet.

Edited, Sep 3rd 2006 at 3:15am EDT by Wint
#5 Sep 03 2006 at 2:22 AM Rating: Decent
**
261 posts
awesome
I will try out what you suggested.
many thanks and any more info would be great^^
Reply To Thread

Colors Smileys Quote OriginalQuote Checked Help

 

Recent Visitors: 9 All times are in CST
Anonymous Guests (9)