Jump to content

Recommended Posts

Posted

I am writting a console application in C# (actually my first C# app)*and I want to clean up/simplify my code:

 

this*is part of what i am dealing with*what I currently have

Console.WriteLine("");

// ****************************************

// OS

// ****************************************

*** string strOS = Environment.GetEnvironmentVariable("OS");

*** Console.Write("****** Operating System ");

*** Console.Write(Environment.GetEnvironmentVariable("OS"));

*** int OS = 0;

*** do { Console.Write(" "); OS++; }

*** while (OS < 91 - strOS.Length);

*** Console.Write("");

*** Console.WriteLine("");

// ****************************************

// NUMBER_OF_PROCESSORS

// ****************************************

*** string strNUMBER_OF_PROCESSORS = Environment.GetEnvironmentVariable("NUMBER_OF_PROCESSORS");

*** Console.Write("** Number of Processors ");

*** Console.Write(Environment.GetEnvironmentVariable("NUMBER_OF_PROCESSORS"));

*** int NUMBER_OF_PROCESSORS = 0;

*** do { Console.Write(" "); NUMBER_OF_PROCESSORS++; }

*** while (NUMBER_OF_PROCESSORS < 91 - strNUMBER_OF_PROCESSORS.Length);

*** Console.Write("");

*** Console.WriteLine("");

// ****************************************

// BACK TO THE REST

Console.WriteLine("");

Console.WriteLine("");

Console.ResetColor();

That displays

 

****** Operating System Windows_NT********************************************************************************

** Number of Processors 4*****************************************************************************************

 

Basically I want to make a class called Format Interface that will simplify the creation of the above.* This is what I have so far but I can't seem to get spaces to format right

*** public class FinishInterface

*** {

******* public string text;

******* public string varName;

******* public FinishInterface(string text, string varName)

******* {

*********** this.text = text;

*********** this.varName = varName;

******* }

******* public void TheRest()

******* {

*********** Console.Write("****** Operating System ");

*********** Console.Write(text);

*********** int varName = 0;

*********** do { Console.Write(" "); varName++; }

*********** while (varName < 91 - text.Length);

*********** Console.Write("");

*********** Console.WriteLine("");

******* }

*** }

 

Then I would call it with

FinishInterface FI = new FinishInterface(Environment.GetEnvironmentVariable("OS"), "OS");

FI.TheRest();

Any suggestions?

 

More...

 

View All Our Microsoft Related Feeds

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...