Click here to Skip to main content
15,892,005 members
Home / Discussions / C#
   

C#

 
Questionregistry handling Pin
Mostafa Siraj21-Aug-06 20:52
Mostafa Siraj21-Aug-06 20:52 
AnswerRe: registry handling Pin
JacquesDP21-Aug-06 22:44
JacquesDP21-Aug-06 22:44 
QuestionApplication.CurrentCulture Pin
M Riaz Bashir21-Aug-06 20:36
M Riaz Bashir21-Aug-06 20:36 
AnswerRe: Application.CurrentCulture Pin
Andrei Ungureanu21-Aug-06 21:02
Andrei Ungureanu21-Aug-06 21:02 
QuestionHow to Extend Datagrid Pin
sanah s21-Aug-06 19:16
sanah s21-Aug-06 19:16 
QuestionDataGrid control scrolls unexpectedly when you use the arrow keys to move (Visual Studio .NET 2003) [modified] Pin
Kiterq21-Aug-06 18:08
Kiterq21-Aug-06 18:08 
QuestionArrayList & Sub ArrayList Import CSV? Pin
gman4421-Aug-06 17:15
gman4421-Aug-06 17:15 
AnswerRe: ArrayList & Sub ArrayList Import CSV? Pin
leppie21-Aug-06 17:54
leppie21-Aug-06 17:54 
kvnsdr wrote:
Q. How would I split this , and - delimited string into a string [,] array?

<FONT color=Blue>public</FONT> <FONT color=Blue>static</FONT> <FONT color=Blue>string</FONT><FONT color=DarkBlue>[]</FONT> Tokenize<FONT color=DarkBlue>(</FONT><FONT color=Blue>string</FONT> name<FONT color=DarkBlue>,</FONT> <FONT color=Blue>params</FONT> <FONT color=Blue>string</FONT><FONT color=DarkBlue>[]</FONT> delimiters<FONT color=DarkBlue>)</FONT>
<FONT color=DarkBlue>{</FONT>
  <FONT color=Blue>for</FONT> <FONT color=DarkBlue>(</FONT><FONT color=Blue>int</FONT> i <FONT color=DarkBlue>=</FONT> <FONT color=Red>0</FONT><FONT color=DarkBlue>;</FONT> i <FONT color=DarkBlue><</FONT> delimiters<FONT color=DarkBlue>.</FONT><FONT color=Teal>Length</FONT><FONT color=DarkBlue>;</FONT> i<FONT color=DarkBlue>++</FONT><FONT color=DarkBlue>)</FONT>
  <FONT color=DarkBlue>{</FONT>
    delimiters<FONT color=DarkBlue>[</FONT><FONT color=Teal>i</FONT><FONT color=DarkBlue>]</FONT> <FONT color=DarkBlue>=</FONT> Regex<FONT color=DarkBlue>.</FONT>Escape<FONT color=DarkBlue>(</FONT>delimiters<FONT color=DarkBlue>[</FONT><FONT color=Teal>i</FONT><FONT color=DarkBlue>]</FONT><FONT color=DarkBlue>)</FONT><FONT color=DarkBlue>;</FONT>
  <FONT color=DarkBlue>}</FONT>

  <FONT color=Blue>string</FONT> del <FONT color=DarkBlue>=</FONT> <FONT color=Blue>string</FONT><FONT color=DarkBlue>.</FONT>Join<FONT color=DarkBlue>(</FONT><FONT color=Maroon>"|"</FONT><FONT color=DarkBlue>,</FONT> delimiters<FONT color=DarkBlue>)</FONT><FONT color=DarkBlue>;</FONT>

  <FONT color=Teal>Regex</FONT> re <FONT color=DarkBlue>=</FONT> <FONT color=Blue>new</FONT> <FONT color=Teal>Regex</FONT><FONT color=DarkBlue>(</FONT>del<FONT color=DarkBlue>,</FONT> RegexOptions<FONT color=DarkBlue>.</FONT>Compiled<FONT color=DarkBlue>)</FONT><FONT color=DarkBlue>)</FONT><FONT color=DarkBlue>;</FONT>

  List<FONT color=DarkBlue><</FONT><FONT color=Blue>string</FONT><FONT color=DarkBlue>></FONT> tokens <FONT color=DarkBlue>=</FONT> <FONT color=Blue>new</FONT> <FONT color=Teal>List</FONT><FONT color=DarkBlue><</FONT><FONT color=Blue>string</FONT><FONT color=DarkBlue>></FONT><FONT color=DarkBlue>(</FONT><FONT color=DarkBlue>)</FONT><FONT color=DarkBlue>;</FONT>
  <FONT color=Blue>int</FONT> lastend <FONT color=DarkBlue>=</FONT> <FONT color=Red>0</FONT><FONT color=DarkBlue>;</FONT>

  <FONT color=Blue>foreach</FONT> <FONT color=DarkBlue>(</FONT><FONT color=Teal>Match</FONT> m <FONT color=Blue>in</FONT> re<FONT color=DarkBlue>.</FONT>Matches<FONT color=DarkBlue>(</FONT>name<FONT color=DarkBlue>)</FONT><FONT color=DarkBlue>)</FONT>
  <FONT color=DarkBlue>{</FONT>
    <FONT color=Blue>if</FONT> <FONT color=DarkBlue>(</FONT>m<FONT color=DarkBlue>.</FONT>Index <FONT color=DarkBlue>></FONT> lastend<FONT color=DarkBlue>)</FONT>
    <FONT color=DarkBlue>{</FONT>
      tokens<FONT color=DarkBlue>.</FONT>Add<FONT color=DarkBlue>(</FONT>name<FONT color=DarkBlue>.</FONT>Substring<FONT color=DarkBlue>(</FONT>lastend<FONT color=DarkBlue>,</FONT> m<FONT color=DarkBlue>.</FONT>Index <FONT color=DarkBlue>-</FONT> lastend<FONT color=DarkBlue>)</FONT><FONT color=DarkBlue>)</FONT><FONT color=DarkBlue>;</FONT>
    <FONT color=DarkBlue>}</FONT>
    tokens<FONT color=DarkBlue>.</FONT>Add<FONT color=DarkBlue>(</FONT>m<FONT color=DarkBlue>.</FONT>Value<FONT color=DarkBlue>)</FONT><FONT color=DarkBlue>;</FONT>
    lastend <FONT color=DarkBlue>=</FONT> m<FONT color=DarkBlue>.</FONT>Index <FONT color=DarkBlue>+</FONT> m<FONT color=DarkBlue>.</FONT>Length<FONT color=DarkBlue>;</FONT>
  <FONT color=DarkBlue>}</FONT>

  tokens<FONT color=DarkBlue>.</FONT>Add<FONT color=DarkBlue>(</FONT>name<FONT color=DarkBlue>.</FONT>Substring<FONT color=DarkBlue>(</FONT>lastend<FONT color=DarkBlue>)</FONT><FONT color=DarkBlue>)</FONT><FONT color=DarkBlue>;</FONT>

  <FONT color=Blue>return</FONT> tokens<FONT color=DarkBlue>.</FONT>ToArray<FONT color=DarkBlue>(</FONT><FONT color=DarkBlue>)</FONT><FONT color=DarkBlue>;</FONT>
<FONT color=DarkBlue>}</FONT>



Questionerror 80040154 at instantiation of COM object Pin
mkrelli21-Aug-06 13:21
mkrelli21-Aug-06 13:21 
AnswerRe: error 80040154 at instantiation of COM object Pin
mav.northwind21-Aug-06 23:30
mav.northwind21-Aug-06 23:30 
GeneralRe: error 80040154 at instantiation of COM object Pin
mkrelli25-Aug-06 14:03
mkrelli25-Aug-06 14:03 
QuestionThe ConnectionString property has not been initialized ! Pin
mostafa_h21-Aug-06 13:11
mostafa_h21-Aug-06 13:11 
AnswerRe: The ConnectionString property has not been initialized ! Pin
Nader Elshehabi21-Aug-06 13:21
Nader Elshehabi21-Aug-06 13:21 
GeneralRe: The ConnectionString property has not been initialized ! Pin
mostafa_h21-Aug-06 13:32
mostafa_h21-Aug-06 13:32 
GeneralRe: The ConnectionString property has not been initialized ! Pin
Steve :)21-Aug-06 14:36
Steve :)21-Aug-06 14:36 
GeneralRe: The ConnectionString property has not been initialized ! Pin
mostafa_h21-Aug-06 20:26
mostafa_h21-Aug-06 20:26 
GeneralRe: The ConnectionString property has not been initialized ! Pin
Nader Elshehabi22-Aug-06 3:47
Nader Elshehabi22-Aug-06 3:47 
GeneralRe: The ConnectionString property has not been initialized ! Pin
Steve :)22-Aug-06 12:42
Steve :)22-Aug-06 12:42 
AnswerRe: The ConnectionString property has not been initialized ! Pin
Coding C#21-Aug-06 20:26
Coding C#21-Aug-06 20:26 
QuestionmouseMove event Pin
jamsiro21-Aug-06 12:49
jamsiro21-Aug-06 12:49 
AnswerRe: mouseMove event Pin
Shy Agam21-Aug-06 13:06
Shy Agam21-Aug-06 13:06 
AnswerRe: mouseMove event Pin
Nader Elshehabi21-Aug-06 13:18
Nader Elshehabi21-Aug-06 13:18 
QuestionRepresent CSS in C# [modified] Pin
Goebel21-Aug-06 12:32
Goebel21-Aug-06 12:32 
QuestionError: "Call was rejected by callee" Pin
Goalie3521-Aug-06 11:49
Goalie3521-Aug-06 11:49 
AnswerRe: Error: "Call was rejected by callee" Pin
bradsnobar21-Aug-06 12:13
bradsnobar21-Aug-06 12:13 

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.