Click here to Skip to main content
15,891,704 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
here is my code em trying to Convert C++ Code in C#. But the main prob is in Functions/Methods. i am confusing in If any body here to clear me these things. Thanks


C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace tt
{
    class Program
    {
        static void Main(string[] args)
        {
             {
     day b;
     teacher s;
     int x;
     int y;
Console.WriteLine("/n,/n,/n,/n");
Console.WriteLine("      -----------------ALL DAY TIME SCHEDULE------------------");
Console.WriteLine("/n,/n,/n,/n");
Console.WriteLine("time-- 8.00    8.50    9.40    10.40    11.30    12.20       2.30");
Console.WriteLine("/n /n");//
Console.WriteLine("day /n");//
Console.WriteLine("  | /n")   ;//
Console.WriteLine("  |");///
Console.WriteLine("/n");
      b.sun();
Console.WriteLine("/n,/n,/n");
     b.mon();
Console.WriteLine("/n,/n,/n");
     b.tue();
Console.WriteLine("/n,/n,/n");
    b.wed();
Console.WriteLine("/n,/n,/n");
     b.thu();
Console.WriteLine("/n,/n,/n");
Console.WriteLine("                          ******END******            ");
                 Console.WriteLine("/n,/n,/n");
 Console.ReadKey();
Console.WriteLine("you can do the following::enter your appropriate option");
                 Console.WriteLine("/n,/n,/n");
Console.WriteLine("routine only a day ");
                 Console.WriteLine("/n,/n,");
Console.WriteLine(endl<<"1:sun");
                 Console.WriteLine("/n");
Console.WriteLine(endl<<"2:mon");
                 Console.WriteLine("/n");
Console.WriteLine(endl<<"3:tue"<<endl;
Console.WriteLine(endl<<"4:wed"<<endl;
Console.WriteLine(endl<<"5:thu"<<endl;
Console.WriteLine(endl<<"6:Quit"<<endl;
Console.WriteLine("/n,/n,/n");
Console.WriteLine("If you not need the one day schedule enter:6");
                 Console.WriteLine("/n,/n");
Console.WriteLine("Enter your choice::");
Console.WriteLine("/n,/n,/n");
Console.WriteLine("time--- 8.00    8.50    9.40    10.40    11.30    12.20       2.30");
Console.WriteLine("/n,/n,/n");

 do
  {
    x = Convert.ToInt32( Console.ReadKey());
    if(x>5)
    break;
   Console.WriteLine("/n,/n");

    switch(x)
    {

   case 1:
     b.sun();
     break;
   case 2:
     b.mon();
     break;
   case 3:
     b.tue();
     break;
   case 4:
     b.wed();
     break;
   case 5:
     b.thu();
     break;
   default:
     break;

   }
  Console.WriteLine("/n,/n,/n");
   }while(x<=5);


Console.WriteLine("Are you want the teacher schedule:");
Console.WriteLine("/n,/n,/n");
Console.WriteLine("/n","1:T-AJHER");//
Console.WriteLine(endl<<"2:T-NAWAJ"<<endl;
Console.WriteLine(endl<<"3:T-RAJIB"<<endl;
Console.WriteLine(endl<<"4:T-SHABUR"<<endl;
Console.WriteLine(endl<<"5:T-DABROTO"<<endl;
Console.WriteLine(endl<<"6:T-JAHID"<<endl;
Console.WriteLine(endl<<"7:T-ARIF"<<endl;
Console.WriteLine(endl<<"8:T-MORSHAD"<<endl;
Console.WriteLine(endl<<"9:T-AGIJ"<<endl;
Console.WriteLine(endl<<"10:T-SULTAN"<<endl;
Console.WriteLine(endl<<"11:T-LIAJE"<<endl;
Console.WriteLine(endl<<"12:T-MD.MOHAMOD"<<endl;
Console.WriteLine(endl<<"13:Quit";
Console.WriteLine(endl<<endl<<endl;
Console.WriteLine("IF YOU DO NOT WANT THIS SCHEDULE ENTER:12");
                 Console.WriteLine("/n,/n");
Console.WriteLine("Enter your choice::";
Console.WriteLine("/n,/n,/n"); //less then 12
 do
  {
    y= Convert.ToInt32(Console.ReadKey());
    if(y>12)
    break;
   Console.WriteLine("/n,/n,/n");
   Console.WriteLine("time--- 8.00    8.50    9.40    10.40    11.30    12.20       2.30");
   Console.WriteLine("/n,/n,/n");

    switch(y)
    {

   case 1:
     s.t_AJHER();
     break;
   case 2:
     s.t_NAWAJ();
     break;
   case 3:
     s.t_RAJIB();
     break;
   case 4:
     s.t_SHABUR();
     break;
   case 5:
     s.t_DABROTO();
     break;
   case 6:
     s.t_JAHID();
     break;
   case 7:
     s.t_ARIF();
     break;
   case 8:
     s.t_MORSHAD();
     break;
   case 9:
     s.t_AGIJ();
     break;
   case 10:
    s.t_SULTAN();
    break;
   case 11:
    s.t_LIAJE();
   case 12:
    s.t_MOHAMOD();
   default:
     break;
   }
  Console.WriteLine("/n,/n,/n");
   }
 while(x<=12);
   Console.WriteLine("--------------------********END*********------------------");
     Console.ReadKey();
     return 0;
  }


    }
    class day
    {
public sun()
{
        Console.WriteLine("sun     cse     eee                                           L cse(A-group)";
 Console.WriteLine("/n,/n");
 Console.WriteLine("        RAJIB   SHABUR                                       AJHER & NAWAJ   ");
    return 0;
     }
    mon()
{
        Console.WriteLine("mon     mat    cse     che      eee               L me1270 ");
        Console.WriteLine("/n,/n");
        Console.WriteLine("        JAHID           AJHER   MORSHAD  DABROTO             LIAJE & SULTAN ");

    return 0;
     }
    tue()
{
        Console.WriteLine("tue     mat     che     cse     cse                          L cse(B-group)");
        Console.WriteLine("/n,/n");
 Console.WriteLine("        ARIF    AGIJ    NAZRUL  NAWAJ                        AJHER & NAWAJ   ");

    return 0;
     }
    wed()
{
        Console.WriteLine("wed     -eeelab(A-group)-----   cse      eee                 Lab  Hum        ");
 Console.WriteLine("/n,/n");
 Console.WriteLine("         SHABUR                 RAJIB   DABROTO              MD.MOHAMOD     ");

    return 0;
     }
    thu()
{
        Console.WriteLine("thu     che     cse     mat     ------che(lab)--------       Leeelab(B-group)");
 Console.WriteLine("/n,/n");
 Console.WriteLine("       MORSHAD  RAJIB   JAHID        MORSHAD                 AJHER & NAWAJ   ");
    return 0;
     }
      }
          //******************End of day class*********************//
           //--------**********************---------//



    class teacher
{
  public t_AJHER()
{
      Console.WriteLine("sun                                                         Lcse(A-group)    ");
 Console.WriteLine("/n,/n");
 Console.WriteLine("mon                     cse                                                   ");
 Console.WriteLine("/n,/n");
 Console.WriteLine("tue                                                         Lcse(B-group)     ");
 Console.WriteLine("/n,/n");
 return 0;
     }
    t_NAWAJ()
{
 Console.WriteLine("sun                                                         Lcse(A_group)    ");
 Console.WriteLine("/n,/n");
 Console.WriteLine("tue                             cse                         Lcse(B-group)    ");
 Console.WriteLine("/n,/n");
 Console.WriteLine("thu             cse                                                          ") ;
 Console.WriteLine("/n,/n");
    return 0;
     }

 t_RAJIB()
{
     Console.WriteLine("                cse                                                ");
 Console.WriteLine("/n,/n");
 Console.WriteLine("tue                     cse                                                 ");
 Console.WriteLine("/n,/n");
 Console.WriteLine("wed                             cse                                         ");
 Console.WriteLine("/n,/n");
    return 0;
     }
t_SHABUR()
{
    Console.WriteLine("sun             eee                                                        ");
 Console.WriteLine("/n,/n");
 Console.WriteLine("wed     -eeelab(A-group)---                                                 ");
 Console.WriteLine("/n,/n");
 Console.WriteLine("                                                            Leeelab(B-group)");
 Console.WriteLine("/n,/n");
    return 0;
     }

t_DABROTO()

{
    Console.WriteLine("mon                                      eee                                ");
Console.WriteLine("/n,/n");
Console.WriteLine("wed                                       eee                                  ");
Console.WriteLine("/n,/n");
    return 0;
     }
t_JAHID()

{
    Console.WriteLine("mon     mat                                                                 ");
 Console.WriteLine("/n,/n");
 Console.WriteLine("thu                     mat                                                  ");
  Console.WriteLine("/n,/n");
    return 0;
     }
 t_ARIF()

{
     Console.WriteLine("tue     mat                                                                    ");
 Console.WriteLine(endl<<endl;
  return 0;
     }
 t_MORSHAD()
{
     Console.WriteLine("tue            che                                                           ");
 Console.WriteLine("/n,/n");
 Console.WriteLine("thu     che                    ------che(lab)----------                     ");


 Console.WriteLine("/n,/n");
  return 0;
    }
t_AGIJ()
{
    Console.WriteLine("mon                             che                                          ");
 Console.WriteLine("/n,/n");
  return 0;
   }
t_LIAJE()
{
 Console.WriteLine("mon                                                          L me1270-F,T ");
 Console.WriteLine("/n,/n");
  return 0;
       }
t_SULTAN()

{
    Console.WriteLine("mon                                                          L me1270-F,T ");
 Console.WriteLine("/n,/n");
  return 0;
  }
t_MOHAMOD()
 {

 Console.WriteLine("                                                             Lab Hum   ");
   return 0;
   }
   }


    //********************************************************//
          //END TEACHER CLASS//
       //"*********************************************"//


}
Posted
Updated 29-Nov-13 10:53am
v2
Comments
AnthonyMG 29-Nov-13 13:33pm    
Please be specific,take a single C++ method which your trying to convert in C# and post only that piece of code. it will be more clear. also mention exactly what issue you are facing.
PIEBALDconsult 29-Nov-13 13:35pm    
What language is:
Console.WriteLine(endl<<"3:tue"<<endl;
Console.WriteLine(endl<<"4:wed"<<endl;
Console.WriteLine(endl<<"5:thu"<<endl;
Console.WriteLine(endl<<"6:Quit"<<endl;
?
Member 9411249 29-Nov-13 13:40pm    
its a C++ Code i m trying to convert it in C#
Sergey Alexandrovich Kryukov 29-Nov-13 16:55pm    
No. You are not showing any C++ code, only some really bad C# code. What's the use of this post? Only the abuse. AntonyMG gave you a good advice above. Use "Improve question" above.
—SA
Maciej Los 29-Nov-13 18:14pm    
Abuse? Not sure. Please, see my answer ;)

Rather than convert C++ code into C#[^], try to understand what it does. Then write it using C# and .NET objects, methods, etc.

Here is some useful information: C++ -> C#: What You Need to Know to Move from C++ to C#[^]
 
Share this answer
 
Comments
Nelek 29-Nov-13 18:00pm    
Nice one the second link. I'll read it slow in other moment. Thanks
Maciej Los 29-Nov-13 18:07pm    
Thank you, Nelek ;)
Sergey Alexandrovich Kryukov 29-Nov-13 18:26pm    
Yes, nice links, should be helpful, a 5.
—SA
Maciej Los 29-Nov-13 18:29pm    
Thank you, Sergey ;)
First obvious. Every method should have return type.

For example:

C#
public sun()


should be declared:

C#
public int sun()


It looks like your methods return always 0, but you are not using returned values in your code. So perhaps you should considere removing
return 0; lines and declare your methods like:

C#
public void sun()


Now try to compile it and see what other errors you are getting.
 
Share this answer
 
Comments
Member 9411249 29-Nov-13 13:38pm    
OK thanks
Member 9411249 29-Nov-13 13:43pm    
public void mon()
{
Console.WriteLine("mon mat cse che eee L me1270 ");
Console.WriteLine("/n,/n");
Console.WriteLine(" JAHID AJHER MORSHAD DABROTO LIAJE & SULTAN ");

return 0;
}

It is true? if its then its giving redline under return 0
Adam Zgagacz 29-Nov-13 13:47pm    
if you declare with 'void', you need to remove "return 0;" line.
Member 9411249 29-Nov-13 13:48pm    
Ohh Sorry
Member 9411249 29-Nov-13 13:57pm    
Console.WriteLine(endl<<"2:T-NAWAJ"<<endl;??
COnsole.WriteLine("/n"+"NAWAJ"+"/n"); it is true?

how to give line break in C# in one line?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900