c# vs2008
HI:
I have to replace a string with somevalue, I use the case
any Ideas how to better implement this (avoid regex if possible).
(was thinking of a dictionary?)
thanks
case "a"
myvar = "1a"
break
case "w"
myvar = "bb"
break
case "L"
myvar = "po"
break 4 1499
"raulavi" <ra*****@discussions.microsoft.comwrote in message
news:C6**********************************@microsof t.com...
c# vs2008
HI:
I have to replace a string with somevalue, I use the case
any Ideas how to better implement this (avoid regex if possible).
(was thinking of a dictionary?)
thanks
case "a"
myvar = "1a"
break
case "w"
myvar = "bb"
break
case "L"
myvar = "po"
break
You'be answered your own question. Use a dictionary.
--
Anthony Jones - MVP ASP/ASP.NET
On Aug 26, 11:29*am, raulavi <raul...@discussions.microsoft.com>
wrote:
c# vs2008
HI:
I have to replace a string with somevalue, I use the case
any Ideas how to better implement this (avoid regex if possible).
(was thinking of a dictionary?)
thanks
case "a"
* * myvar = "1a"
* *break
case "w"
* * myvar = "bb"
* *break
case "L"
* * myvar = "po"
* * break
A dictionary could be used, but I think that you need to explain
better your escenario, like if the possible values change both of the
to be replaced string and the replacing string.
In your code you are not "replacing" you are simply assigning
If all you need is a state machine, a dictionary works rather nicely.
Dictionary<string,stringeven better, as you end up typing the objects for
key and value.
--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA
Subscribe to my blog http://feeds.feedburner.com/GregoryBeamer#
or just read it: http://feeds.feedburner.com/GregoryBeamer
********************************************
| Think outside the box! |
********************************************
"raulavi" <ra*****@discussions.microsoft.comwrote in message
news:C6**********************************@microsof t.com...
c# vs2008
HI:
I have to replace a string with somevalue, I use the case
any Ideas how to better implement this (avoid regex if possible).
(was thinking of a dictionary?)
thanks
case "a"
myvar = "1a"
break
case "w"
myvar = "bb"
break
case "L"
myvar = "po"
break
thanks to all
the scenario is very basic...
long lists everywhere
there are many pair (case) every where in this c# code (framework 2.0) I
will love to use linq, but will wait for 3.0
I would like to organize them nicelly as:
listIn = "a,w,L..."
listOut = "1a,bb,po..."
myvar = for listIn use listOut;
(nice future feature eh?)
"Ignacio Machin ( .NET/ C# MVP )" wrote:
On Aug 26, 11:29 am, raulavi <raul...@discussions.microsoft.com>
wrote:
c# vs2008
HI:
I have to replace a string with somevalue, I use the case
any Ideas how to better implement this (avoid regex if possible).
(was thinking of a dictionary?)
thanks
case "a"
myvar = "1a"
break
case "w"
myvar = "bb"
break
case "L"
myvar = "po"
break
A dictionary could be used, but I think that you need to explain
better your escenario, like if the possible values change both of the
to be replaced string and the replacing string.
In your code you are not "replacing" you are simply assigning This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Joe Stevenson |
last post by:
Hi all,
I skimmed through the docs for Python, and I did not find anything like
a case or switch statement. I assume there is one and that I just
missed it. Can someone please point me to the...
|
by: deanfamily11 |
last post by:
I've set up a case statement to have my program determine where on the
Cartesian plane a point the user enters is located. I keep getting the
C2051 error when I compile. Any help?
#include...
|
by: Sameer |
last post by:
Hi friends,
I am beginner in C++. I am using g++ compiler. below is my code
which gives error as " invlid conversion from 'char' to 'const char*'
..Plz help me with this.
#include <iostream.h>...
|
by: Fei Liu |
last post by:
Hi Group, I've got a problem I couldn't find a good solution. I am
working with scientific data files in netCDF format. One of the
properties of netCDF data is that the actual type of data is only...
|
by: betbubble |
last post by:
I need help on two questions:
1. Is temp table the only way to pass recordsets from a nested stored
procedure to a calling stored procedure? Can we avoid temp tables in
this case?
2. Are...
|
by: Angel Of Death |
last post by:
I have a method. It takes some XML as a parameter. Depending on the
content of the XML it should create a specific object and call a KNOWN
method.
So: public void PersistXml(string XmlData){}
...
|
by: Fir5tSight |
last post by:
Hi All,
I have a "SELECT" statement in a stored procedure that looks like the
follows:
...
|
by: digz |
last post by:
This is a very simplified version of something I am trying to
understand.
The State object holds the strings and maps , and I pass a reference
to State to the process Function which manipulates it...
|
by: CK |
last post by:
How do I write a set based query? I have a groupSets table with fields
setId, idField, datasource, nameField, prefix, active
Data:
1,someIDfield, someTable, someField, pre1, 1
2,someotherIDfield,...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
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...
|
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...
|
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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
| |