Beginner C# student

surfhick

Junior Member
Jan 6, 2008
18
0
0
I'm still doing just very simple programs. Console applications. I like to play around and see how good I can make my output. In fact, just today I discovered Console.Clear(). I had been just using empty strings to create spaces. I was working on a program that had acculating totals. I was able to make those totals display in the same spot, even when they updated. Of course, I had to comment this ability out because my teacher will probably doc me as it wasn't in the program spec.

All this playing around made me wonder if there is a way to change the text color. Easy to do if working with forms and such but what about in a console app? I think I've seen things that will let me change some of the windows attributes. Like backcolor, size(width and height) and such. I haven't figured out how to use them yet.

Is it possible to change the text's color?
 

surfhick

Junior Member
Jan 6, 2008
18
0
0
Thank you nod218, thats exactly what I was searching for. I never thought about searching support. I spent all day in Developer Center, Help, and various web sites.
In all , I spent alot more time looking for this than I did writing the program. Next time
I make a dividing line it will be in color.
 

sourceninja

Diamond Member
Mar 8, 2005
8,805
65
91
I sometimes wonder if it is a good or a bad thing that programing has reached a point where we no longer wonder how to do something, but rather what built in function to use.
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
Originally posted by: sourceninja
I sometimes wonder if it is a good or a bad thing that programing has reached a point where we no longer wonder how to do something, but rather what built in function to use.

As opposed to figuring out which built in ANSI code to use?
 

Leros

Lifer
Jul 11, 2004
21,867
7
81
Originally posted by: sourceninja
I sometimes wonder if it is a good or a bad thing that programing has reached a point where we no longer wonder how to do something, but rather what built in function to use.

That's the whole point of abstraction. Let somebody else write the system level code. Then you can focus on your program instead of how to do basic tasks like output.
 

surfhick

Junior Member
Jan 6, 2008
18
0
0
Like I said, I'm still at a very beginner level. In fact, I can't even begin to understand the code snippet nod218 linked me to. I can use it but have no idea how it works as of now. My book went through using strings fairly quickly. I bet there aren't 3 full pages devoted to using them and it gave only a few methods for formatting output. ToString("C"), just a few other very basic ones. I definately feel more could be said on the subject. Perhaps its a topic that will come up later after more advanced concepts have been presented.

When I asked the question I was thinking I might get something like:
using something
something.somethingElse()

That link has other links on it. Filled with all kinds of Console functions to explore. I found Console.clear() on my own. All it took was the hair to try it as it was right there when I clicked Console.. Now its like I have this whole new world to explore.
 

surfhick

Junior Member
Jan 6, 2008
18
0
0
After all that reading look how easy it is.

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

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.BackgroundColor = ConsoleColor.Black;
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Hey");
}
}
}

Writes 'Hey' in red text.
 

degibson

Golden Member
Mar 21, 2008
1,389
0
0
Neat.
Query: Does it leave the console in FG/Red BG/Black mode after it terminates? Or does the library clean up the console?
 

surfhick

Junior Member
Jan 6, 2008
18
0
0
The console colors will remain. Even after the program terminates. You have to use:

Console.ResetColor(); To return the colors back to normal.

To reset just the ForeGround color you would have to use Console.ForegroundColor
and set it back to the original color. Grey.
 

plastick

Golden Member
Sep 29, 2003
1,400
1
81
Originally posted by: Leros
Originally posted by: sourceninja
I sometimes wonder if it is a good or a bad thing that programing has reached a point where we no longer wonder how to do something, but rather what built in function to use.

That's the whole point of abstraction. Let somebody else write the system level code. Then you can focus on your program instead of how to do basic tasks like output.

Yeah you're right. I dont know why some people dont realize this. I guess it indicates their level of thought. Its so nice to have levels of abstraction that one may traverse and change as needed. This profoundly increases ease of use AND control. Everything is supposed to be like that.
 

degibson

Golden Member
Mar 21, 2008
1,389
0
0
Originally posted by: plastick
Originally posted by: Leros
Originally posted by: sourceninja
I sometimes wonder if it is a good or a bad thing that programing has reached a point where we no longer wonder how to do something, but rather what built in function to use.

That's the whole point of abstraction. Let somebody else write the system level code. Then you can focus on your program instead of how to do basic tasks like output.

Yeah you're right. I dont know why some people dont realize this. I guess it indicates their level of thought. Its so nice to have levels of abstraction that one may traverse and change as needed. This profoundly increases ease of use AND control. Everything is supposed to be like that.

It's been a long long time since we've had to do anything 'ourselves'. True, today we can do Console.ForegroundColor(), whereas yesterday we did something like printf("\033[31;1m"), but at least we're not banging bits at video cards to change pixel colors.

However, I think there's a flipside to this. How would you guys go about making a single pixel, say, red, in command-line mode? How many libraries would it require? Is this a good example about how maybe, just maybe, our abstractions (while great) are sometimes too limiting?

Edit: That is to say, I'd bet that there are ~7 assembly instructions that need to be executed in the display driver to make this happen. How much bloat is added to this by our abstractions?
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |