Click here to Skip to main content
15,895,462 members
Home / Discussions / C#
   

C#

 
AnswerRe: beginer in c# Pin
V.16-Jan-12 23:08
professionalV.16-Jan-12 23:08 
AnswerRe: beginer in c# Pin
Richard MacCutchan16-Jan-12 23:10
mveRichard MacCutchan16-Jan-12 23:10 
AnswerRe: beginer in c# Pin
thatraja16-Jan-12 23:11
professionalthatraja16-Jan-12 23:11 
QuestionHow To Track [ Inserted/Updated ] Records Using ADO.NET Pin
AmbiguousName16-Jan-12 21:17
AmbiguousName16-Jan-12 21:17 
AnswerRe: How To Track [ Inserted/Updated ] Records Using ADO.NET Pin
Mycroft Holmes16-Jan-12 21:54
professionalMycroft Holmes16-Jan-12 21:54 
AnswerRe: How To Track [ Inserted/Updated ] Records Using ADO.NET Pin
BobJanova16-Jan-12 22:42
BobJanova16-Jan-12 22:42 
QuestionC# Limit number of characters user can enter - Console Application Pin
Deborah Palmer McCain16-Jan-12 12:08
Deborah Palmer McCain16-Jan-12 12:08 
AnswerRe: C# Limit number of characters user can enter - Console Application Pin
Wayne Gaylard16-Jan-12 18:46
professionalWayne Gaylard16-Jan-12 18:46 
Instead of using Console.ReadLine you are going to have to use Console.ReadKey. Something along the lines of this:-

C#
string str = string.Empty;
               while (str.Length <= 5)
               {
                   char c = Console.ReadKey(true).KeyChar;
                   if (c == '\r')
                   {
                       //user pressed enter
                       break;
                   }
                   if (c == '\b')
                   {
                       //User pressed backspace
                       if (str != string.Empty)
                       {
                           str = str.Substring(0, str.Length - 1);
                           Console.Write("\b \b");
                       }
                   }
                   int enteredValue;
                   if(Int32.TryParse(c.ToString(), out enteredValue))
                   {
                       Console.Write(c);
                       str += c;
                   }
               }
               Console.WriteLine();
               Console.WriteLine("You entered " + str);
               Console.ReadLine();


This checks if the char entered is numeric, it handles backspaces and it checks to see if the user pressed enter. I am sure you could alter this to work with your app.

Hope it helps
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman

GeneralRe: C# Limit number of characters user can enter - Console Application Pin
Deborah Palmer McCain16-Jan-12 19:04
Deborah Palmer McCain16-Jan-12 19:04 
GeneralRe: C# Limit number of characters user can enter - Console Application Pin
Wayne Gaylard16-Jan-12 19:14
professionalWayne Gaylard16-Jan-12 19:14 
AnswerRe: C# Limit number of characters user can enter - Console Application Pin
BobJanova16-Jan-12 22:39
BobJanova16-Jan-12 22:39 
GeneralRe: C# Limit number of characters user can enter - Console Application Pin
Deborah Palmer McCain17-Jan-12 4:53
Deborah Palmer McCain17-Jan-12 4:53 
Questionhow to paint lines on combo-box in difference colors ? Pin
goldsoft16-Jan-12 0:25
goldsoft16-Jan-12 0:25 
AnswerRe: how to paint lines on combo-box in difference colors ? Pin
Pete O'Hanlon16-Jan-12 0:29
mvePete O'Hanlon16-Jan-12 0:29 
GeneralRe: how to paint lines on combo-box in difference colors ? Pin
goldsoft16-Jan-12 0:38
goldsoft16-Jan-12 0:38 
AnswerRe: how to paint lines on combo-box in difference colors ? Pin
Luc Pattyn16-Jan-12 0:47
sitebuilderLuc Pattyn16-Jan-12 0:47 
GeneralRe: how to paint lines on combo-box in difference colors ? Pin
BobJanova16-Jan-12 3:43
BobJanova16-Jan-12 3:43 
Questionhelp Pin
rudra12415-Jan-12 21:03
rudra12415-Jan-12 21:03 
AnswerRe: help Pin
Mycroft Holmes15-Jan-12 21:08
professionalMycroft Holmes15-Jan-12 21:08 
AnswerRe: help Pin
OriginalGriff15-Jan-12 21:26
mveOriginalGriff15-Jan-12 21:26 
GeneralRe: help Pin
Luc Pattyn15-Jan-12 21:38
sitebuilderLuc Pattyn15-Jan-12 21:38 
AnswerRe: help Pin
thatraja16-Jan-12 2:13
professionalthatraja16-Jan-12 2:13 
QuestionWindows service Windows XP and Windows 7 Pin
Mc_Topaz15-Jan-12 20:58
Mc_Topaz15-Jan-12 20:58 
AnswerRe: Windows service Windows XP and Windows 7 Pin
Luc Pattyn15-Jan-12 21:42
sitebuilderLuc Pattyn15-Jan-12 21:42 
AnswerRe: Windows service Windows XP and Windows 7 Pin
Mc_Topaz15-Jan-12 22:22
Mc_Topaz15-Jan-12 22:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.