Click here to Skip to main content
15,914,419 members
Home / Discussions / C#
   

C#

 
QuestionHelping -- winpcap & winDump libraries for capture and dump IP packets using C# Pin
3bood.ghzawi5-Nov-09 2:21
3bood.ghzawi5-Nov-09 2:21 
Questionsizeof struct with array Pin
Ronenb5-Nov-09 2:03
Ronenb5-Nov-09 2:03 
AnswerRe: sizeof struct with array Pin
Luc Pattyn5-Nov-09 2:23
sitebuilderLuc Pattyn5-Nov-09 2:23 
GeneralRe: sizeof struct with array Pin
Ronenb7-Nov-09 19:16
Ronenb7-Nov-09 19:16 
GeneralRe: sizeof struct with array Pin
Luc Pattyn8-Nov-09 1:07
sitebuilderLuc Pattyn8-Nov-09 1:07 
GeneralRe: sizeof struct with array Pin
Ronenb8-Nov-09 4:36
Ronenb8-Nov-09 4:36 
QuestionSplit Name Field Pin
kruegersck5-Nov-09 1:58
kruegersck5-Nov-09 1:58 
AnswerRe: Split Name Field Pin
musefan5-Nov-09 2:30
musefan5-Nov-09 2:30 
Its a tricky one because you have a number of possibilities, i.e. Title and middle names.

If this was a one of process I would use manual intervention, but would also have fields for title.

Do you want to retain the title anywhere? where should the middle name be included? I would put the middle name with the forename if I only had two fields (forename, surname)

Why don't you try something like...


void GetMeSomeNames(string fullname, out string forename, out string surname)
{
  forename = surname = "";
  string[] names = fullname.Split(' ', StringFormatOptions.RemoveEmptyEntries);
  if(names.length == 0)
    return;
  if(names.length == 1)
  {
    forename = names[0];//or surname if preferred
    return;
  }
  
  bool hasTitle = false;
  switch(names[0].ToLowerInvarient())
  {
    case "dr":
       hasTitle = true;
    case "mr":
       hasTitle = true;
    //etc...
  }
  for(int i = (hasTitle ? 1 : 0); i < names.length - 1; i++)
    forename += names[i] + " ";
  forename = forename.Trim();
  surname = names[names.length-1];
}


Life goes very fast. Tomorrow, today is already yesterday.

AnswerRe: Split Name Field Pin
Shameel5-Nov-09 2:33
professionalShameel5-Nov-09 2:33 
AnswerRe: Split Name Field Pin
V.5-Nov-09 4:21
professionalV.5-Nov-09 4:21 
AnswerRe: Split Name Field Pin
PIEBALDconsult5-Nov-09 5:34
mvePIEBALDconsult5-Nov-09 5:34 
GeneralRe: Split Name Field Pin
Luc Pattyn5-Nov-09 12:51
sitebuilderLuc Pattyn5-Nov-09 12:51 
QuestionHow to Hide MenuBar/ToolBar while displaying Office Document using Web Browser? Pin
muhammad_umair5-Nov-09 1:22
muhammad_umair5-Nov-09 1:22 
QuestionIs there a better way for updating bound controls when updating the data source manually? Pin
TheFoZ5-Nov-09 0:40
TheFoZ5-Nov-09 0:40 
AnswerRe: Is there a better way for updating bound controls when updating the data source manually? Pin
Gerry Schmitz5-Nov-09 15:34
mveGerry Schmitz5-Nov-09 15:34 
GeneralRe: Is there a better way for updating bound controls when updating the data source manually? Pin
TheFoZ5-Nov-09 22:23
TheFoZ5-Nov-09 22:23 
GeneralRe: Is there a better way for updating bound controls when updating the data source manually? Pin
Gerry Schmitz6-Nov-09 6:57
mveGerry Schmitz6-Nov-09 6:57 
AnswerRe: Is there a better way for updating bound controls when updating the data source manually? Pin
TheFoZ9-Nov-09 23:13
TheFoZ9-Nov-09 23:13 
Generalcasting struct to list<object></object> Pin
manowj4-Nov-09 23:43
manowj4-Nov-09 23:43 
GeneralRe: casting struct to list Pin
OriginalGriff5-Nov-09 0:14
mveOriginalGriff5-Nov-09 0:14 
GeneralRe: casting struct to list [modified] Pin
manowj5-Nov-09 0:35
manowj5-Nov-09 0:35 
GeneralRe: casting struct to list Pin
OriginalGriff5-Nov-09 0:53
mveOriginalGriff5-Nov-09 0:53 
QuestionRead text from notepad in c# Pin
krinaljariwala4-Nov-09 22:43
krinaljariwala4-Nov-09 22:43 
AnswerRe: Read text from notepad in c# Pin
Covean4-Nov-09 23:16
Covean4-Nov-09 23:16 
GeneralRe: Read text from notepad in c# Pin
krinaljariwala4-Nov-09 23:38
krinaljariwala4-Nov-09 23:38 

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.