By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,968 Members | 1,589 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,968 IT Pros & Developers. It's quick & easy.

How to display message in c sharp

P: 4
Dear All,

I am looking for code to display message box in c sharp language and guide line if any other requirement regarding to display message i mean to say that any class or namespeacing is required.


Sajjad Ali
Feb 27 '09 #1
Share this Question
Share on Google+
10 Replies

Expert 100+
P: 427

Well I suppose we have these kinds of questions at some stage, the code is pretty self-explanatory so I will give it to you and you can read up about it using Intillisense.

Expand|Select|Wrap|Line Numbers
  1. System.Windows.Forms.MessageBox.Show("Text goes here");
or to make things easier just type mbox and press <TAB> twice

This method has a huge amount of overloads and you can customize it a lot, so just play around with it.
Feb 27 '09 #2

Expert 100+
P: 750
In case of windows application you can make use of Message Box
and in case of use javascript . Also you can google for ajax message box
Feb 27 '09 #3

P: 4
I code like this given bellow for message but their is a error

missing assemble or like some and the highlighlited windows word that what should i do

global::System.Windows.Forms.MessageBox.Show("Hello world");

Feb 27 '09 #4

Expert 100+
P: 750
Add reference to System.Windows.Forms in your ( i am assuming here a console application) application ... If its a web project ... use javascript... as server side code cant execute on client side ...
Feb 27 '09 #5

P: 4

I am trying to compare data if user select date for birth date field then it will compare today's data and subtract it by 18 year if it is valid then process further other wise send Alert Message that you are not eligible.

For this all what i have to do i am also searching it.

Please do replay.

Apr 2 '09 #7

Expert 100+
P: 427
Your question doesn't seem to have anything to do with this thread. Please start a new relevant thread.

As for calculating if the age is over 18 you could try:

Expand|Select|Wrap|Line Numbers
  1. DateTime MinimumBirthDate, SuppliedBirthDate;
  2. TimeSpan LegalAge = new TimeSpan();
  4. LegalAge = TimeSpan.FromDays(365*18); //to get 18 years
  6. MinimumBirthDate = DateTime.Now.Subtract(LegalAge);
  8. SuppliedBirthDate = new DateTime(1203, 8, 8); //Enter birthdate supplied by the user here
  10. if (MinimumBirthDate > SuppliedBirthDate)
  11. {
  12.       //over 18 code
  13. }
  14. else
  15. {
  16.      //under 18 code
  17. }
Hope this helps
Apr 2 '09 #8

P: 15
I probably wouldn't have spoon fed him the answer, but point him on the right direction.

IE: what methods/procs to use etc
Apr 2 '09 #9

P: 8
Hi Sajjad Ali,

If u did not find out the answer till now, try this...

using System.Windows.Forms
MessageBox.Show("Test Message");
Apr 2 '09 #10

P: 4

I have done this this problem was at the begining level of my coding with c#.

Well thanks i will ask you if i have any other problem with c # code.

Apr 3 '09 #11

Post your reply

Sign in to post your reply or Sign up for a free account.