Thread: question about char's in .net

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    255

    question about char's in .net

    hey

    ok for school i have to get this text exercise to work they gave me code but it has an infinite loop so im fixing it:

    original code:

    Code:
    double sales = 0.0;
    Console::Write("Enter a sa;es amount: ");
    sales = Convert::ToDouble(Console::ReadLine());
    while (sales > 0)
    {
    Console::WriteLine(Sales * .1);
    }// end while
    modified:

    Code:
    double sales = 0.0;
    char exit = ' ';
    while (exit == 'Q')
    	{
    	Console::Write("Enter a sales amount: ");
    	sales = Convert::ToDouble(Console::ReadLine());	
    	Console::WriteLine(sales * .1);
    	Console::Write("Do you want to quit(q)? ");
    	exit = Convert::ToChar(Console::ReadLine());
    	exit = char::toupper(exit);
    	}//End While
    the problem it seems to have is with the char::toupper(exit)
    yet i checked my notes and that is what i see written down so what is .net complaining with char's this time???

    c:\Documents and Settings\Owner\My Documents\Visual Studio Projects\Exercise 19\Exercise 19.cpp(21): error C2062: type 'char' unexpected

    is the error i get and of course it warning me for using a char since .net hates them for some lame reason

    so any ideas why?

    thanks
    hooch

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    C++ is case sensitive:
    Code:
    	exit = Char::ToUpper(exit);
    The .NET framework uses wchar_t rather than char. This may cause warnings. You could change your char declarations to wchar_t.
    Code:
    double sales = 0.0;
    wchar_t exit = L' ';
    while (exit != L'Q')
    	{
    	Console::Write("Enter a sales amount: ");
    	sales = Convert::ToDouble(Console::ReadLine());	
    	Console::WriteLine(sales * .1);
    	Console::Write("Do you want to quit(q)? ");
    	exit = Convert::ToChar(Console::ReadLine());
    	exit = Char::ToUpper(exit);
    	}//End While
    C++.NET appears to be a dead horse. C# is the strongly preferred language for use with the .NET framework.

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    255
    ah thanks alot i was getting confused cause that little drop down menu .net gives never appeared with Char::

    and yea id rather learn normal c/c++ but this is what they are teaching so oh well im sure i can pick it up eventually seems more useful to me
    hooch

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. MSVC++ .NET 2005 Express Question
    By cboard_member in forum Windows Programming
    Replies: 1
    Last Post: 12-08-2005, 08:04 AM
  2. Some .NET Distribution Stats
    By nickname_changed in forum C# Programming
    Replies: 2
    Last Post: 05-14-2005, 03:41 AM
  3. VS .NET & XP Pro Question
    By hk_mp5kpdw in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 01-08-2003, 01:07 PM
  4. Your opinion about .NET
    By Shiro in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 04-05-2002, 02:55 PM
  5. .net
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 02-15-2002, 01:15 AM