473,387 Members | 1,575 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Windows Console App Align

Hi, I'm a rookie about C# and im starting developing some Basic Console
Aplications, but i was just wondering if there's a way to center a message
when using the "Console.WriteLine("");" command, lets say i want the message
to appear centered when running the program. Thank you so much! ;)
Apr 2 '08 #1
2 3916
Not built in (AFAIK) - but you can just pad it manually:

static void Main()
{
WriteLineCentered("foo {0}", "bar");
}
static void WriteLineCentered(string format, params object[]
args)
{
string value = string.Format(format, args);
int padding = (Console.WindowWidth - value.Length) / 2;
if (padding 0)
{
Console.Write(new string(' ',padding));
}
Console.WriteLine(value);
}
Apr 2 '08 #2
On Apr 2, 2:04*am, Fernando Rios
<FernandoR...@discussions.microsoft.comwrote:
Hi, I'm a rookie about C# and im starting developing some Basic Console
Aplications, but i was just wondering if *there's a way to center a message
when using the "Console.WriteLine("");" command, lets say i want the message
to appear centered when running the program. Thank you so much! ;)
Hi,

Not really, you see int he console you can only isntruct to display a
text, but you have no control of how to do it. I'm not aware of any
library that allows you to control and format the console.
Apr 2 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mario | last post by:
i have three rows on my main site i want that the middle-row resizes (only height) depending on the windows size i know it is possible in javascript, but i dont know how ot do it im more like...
1
by: James Carnley | last post by:
I am learning how to use windows forms and I have come across a small problem. Whenever I run my program it opens a console window before launching the windows form. The console doesnt go away...
2
by: Bonnett | last post by:
I have made a simple console application that creates a webpage from my playlist, then uploads it to my webhost. I decided to convert it to a windows service and use the FileSystemWatcher to...
6
by: Mark Allison | last post by:
Hi, I have an application that I want to be to run in Console mode and GUI mode. If no params are entered, I want the GUI fired up, if params are entered, then go into console mode. I believe...
9
by: SP | last post by:
Hi All, I wrote a windows service which is supposed to stop after specified amount of time. I am calling OnStop() after specified time. OnStop() methods executed but I dont see the service...
8
by: RTT | last post by:
i'm writing a windows form but codebased a iwant to run the code as a different user. like in a webapplication you can impersonate a user so the website does not run on the standard ASP.NET...
7
by: programming | last post by:
Hi all, i have been having trouble with a login script that works on my windows machine, however when i upload it to the Unix server through VPN, the same script won't work! It won't parse...
4
by: Peter Nimmo | last post by:
Hi, I am writting a windows application that I want to be able to act as if it where a Console application in certain circumstances, such as error logging. Whilst I have nearly got it, it...
5
AutumnsDecay
by: AutumnsDecay | last post by:
Hey there. So over the time I've been gone, I got engaged. I am now making an information site for my and my fiances wedding. The problem is that on every page I use a table inside a DIV. I do...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.