473,405 Members | 2,310 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Create dynamic Name for string

I want create a string from a row of my db, but for each rows i need a new
string and a new name for the variable.

exemple:
int i = myRow["ID"];
string varName = "news";

createNameVar = varName + i;

but i can't eval this in C#, also the strings news1, new2,...,newsN don't
exist.
How i can do that?
Nov 15 '05 #1
11 15554
KaHuNa <ka****@quickemail.de> wrote:
I want create a string from a row of my db, but for each rows i need a new
string and a new name for the variable.

exemple:
int i = myRow["ID"];
string varName = "news";

createNameVar = varName + i;

but i can't eval this in C#, also the strings news1, new2,...,newsN don't
exist.
How i can do that?


Why do you need a new name for the variable? Why not just use an array?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #2
>
Why do you need a new name for the variable? Why not just use an array?

Because i use the string to send the variable in a Macromedia Flash
interface.
Nov 15 '05 #3
You don't really need a new name for the variable
If you need to hold all the news strings at the same time you can use an
array or ArrayList

ArrayList newsList = new ArrayList();

foreach(row r in table.rows)
{
int i = r["ID"];
newsList.Add("news" + i);
}

newsList will then hold all the strings. You only need the reference, not
the name.

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
For a laugh, try web browsing with Opera's User Mode with Nostalgia enabled
Nov 15 '05 #4
I need a string to send to flash


"Morten Wennevik" <Mo************@hotmail.com> a écrit dans le message de
news:opr1s8yjj9hntkfz@localhost...
You don't really need a new name for the variable
If you need to hold all the news strings at the same time you can use an
array or ArrayList

ArrayList newsList = new ArrayList();

foreach(row r in table.rows)
{
int i = r["ID"];
newsList.Add("news" + i);
}

newsList will then hold all the strings. You only need the reference, not
the name.

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
For a laugh, try web browsing with Opera's User Mode with Nostalgia enabled
Nov 15 '05 #5
KaHuNa <ka****@quickemail.de> wrote:
Why do you need a new name for the variable? Why not just use an array?

Because i use the string to send the variable in a Macromedia Flash
interface.


You need to be a bit clearer on exactly what you're doing here. How
does the Flash interface work, etc. If you could produce a really
"dummy" version of what you're trying to do (which needn't be related
to the real thing) that would help a lot. It could be that reflection
is what you need, but it's hard to say without more information.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #6
You can always send these strings to flash
foreach(string s in newsList)
{
send s to flash
}

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
For a laugh, try web browsing with Opera's User Mode with Nostalgia enabled
Nov 15 '05 #7
ok take this exemple:
you have a text file with a="abc"
you load the line and you have a string, but you can use the variable a.
With eval in jscript you can create a="abc" with a is the variable.
I want the same function in c#, a function which evaluates the string to
make varaibles....

"Morten Wennevik" <Mo************@hotmail.com> a écrit dans le message de
news:opr1tay6uohntkfz@localhost...
You can always send these strings to flash
foreach(string s in newsList)
{
send s to flash
}

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
For a laugh, try web browsing with Opera's User Mode with Nostalgia enabled
Nov 15 '05 #8
KaHuNa <ka****@quickemail.de> wrote:
ok take this exemple:
you have a text file with a="abc"
you load the line and you have a string, but you can use the variable a.
With eval in jscript you can create a="abc" with a is the variable.
I want the same function in c#, a function which evaluates the string to
make varaibles....


Well, you can't - but if you'd explain more *why* you want this, *how*
you were going to use it, we could help to explain what to use instead.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #9
Are you perhaps trying to ouput these values into a text file that is then
read in by Flash (which will then assign values in the text file to
variables within its own programming environment) ?

In that case just output " strings" that you build up into that text file...

Pseudo code:

for each row x in my data...

varForFlash = "news" + x + "=" + dataIwantVarToEqual

Ouput varForFlash to text file

next row

This will give you a text file with:
news1 = firstRowData
news2 = 2ndRowData

etc...

Flash will then be able to consume...

I hope this helps, if not then please provide clearer details on what you
are doing as suggested by the others..

Cheers
Giri
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
KaHuNa <ka****@quickemail.de> wrote:
ok take this exemple:
you have a text file with a="abc"
you load the line and you have a string, but you can use the variable a.
With eval in jscript you can create a="abc" with a is the variable.
I want the same function in c#, a function which evaluates the string to
make varaibles....


Well, you can't - but if you'd explain more *why* you want this, *how*
you were going to use it, we could help to explain what to use instead.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 15 '05 #10
I think this method could be fine, because i can make the eval in flash and
the server works less....
thank you.
"Giri" <gt******@prologis.com> a écrit dans le message de
news:Oe**************@TK2MSFTNGP10.phx.gbl...
Are you perhaps trying to ouput these values into a text file that is then
read in by Flash (which will then assign values in the text file to
variables within its own programming environment) ?

In that case just output " strings" that you build up into that text file...
Pseudo code:

for each row x in my data...

varForFlash = "news" + x + "=" + dataIwantVarToEqual

Ouput varForFlash to text file

next row

This will give you a text file with:
news1 = firstRowData
news2 = 2ndRowData

etc...

Flash will then be able to consume...

I hope this helps, if not then please provide clearer details on what you
are doing as suggested by the others..

Cheers
Giri
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
KaHuNa <ka****@quickemail.de> wrote:
ok take this exemple:
you have a text file with a="abc"
you load the line and you have a string, but you can use the variable a. With eval in jscript you can create a="abc" with a is the variable.
I want the same function in c#, a function which evaluates the string to make varaibles....


Well, you can't - but if you'd explain more *why* you want this, *how*
you were going to use it, we could help to explain what to use instead.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Nov 15 '05 #11
Flash will do that more or less for you :

http://www.flashmove.com/tips/cf/
"KaHuNa" <ka****@quickemail.de> wrote in message
news:40********@news.vo.lu...
I think this method could be fine, because i can make the eval in flash and the server works less....
thank you.
"Giri" <gt******@prologis.com> a écrit dans le message de
news:Oe**************@TK2MSFTNGP10.phx.gbl...
Are you perhaps trying to ouput these values into a text file that is then
read in by Flash (which will then assign values in the text file to
variables within its own programming environment) ?

In that case just output " strings" that you build up into that text file...

Pseudo code:

for each row x in my data...

varForFlash = "news" + x + "=" + dataIwantVarToEqual

Ouput varForFlash to text file

next row

This will give you a text file with:
news1 = firstRowData
news2 = 2ndRowData

etc...

Flash will then be able to consume...

I hope this helps, if not then please provide clearer details on what you are doing as suggested by the others..

Cheers
Giri
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
KaHuNa <ka****@quickemail.de> wrote:
> ok take this exemple:
> you have a text file with a="abc"
> you load the line and you have a string, but you can use the variable a. > With eval in jscript you can create a="abc" with a is the variable.
> I want the same function in c#, a function which evaluates the
string
to > make varaibles....

Well, you can't - but if you'd explain more *why* you want this, *how*
you were going to use it, we could help to explain what to use

instead.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too



Nov 15 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Cindy | last post by:
hi, Can someone point me to a website where I can find a "create dynamic rows" javascript that work for IE, NS6 & NS7? Thank You. regards, Cindy
7
by: Cindy | last post by:
"kaeli" <infinite.possibilities@NOSPAMatt.net> wrote in message news:MPG.197482677bbc284b989702@nntp.lucent.com... > In article <bed8e3$m6r$1@mawar.singnet.com.sg>, stayhardsg@yahoo.com.sg >...
7
by: Bil Muh | last post by:
Esteemede Developers, I would like to Thank All of You in advance for your sincere guidances. I am developing a software using Visual C++ .NET Standard Edition with Windows Form (.NET)...
5
by: plsHelpMe | last post by:
How to create dynamic javascript arrays using dojo toolkits Hello frens, I am in a big trouble. My objective is: I am having some categories shown by differnent radio buttons, on the click of...
0
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I...
4
by: Michael Munch | last post by:
Hi I want to read the value of af text-field, create dynamic, in a form. Se below a small test-site to do that (but readning fails): I use the function Test_Read for reading the value from the...
1
by: Sundhas | last post by:
Hey! I am working on jrxml to create dynamic re0ports. I have parameterized the columns i.e. the jrxml for that report can be used to generate other reports as well. However, i have not managed...
6
by: mabrynda | last post by:
Dear Experts, I have the following problem. I'm generating output txt files from access (an access 2002 table is converted into deleimited text with tabs including field names). For that I have a...
8
by: remya1000 | last post by:
i'm using VB \ ASP.NET. i'm trying to display some values in Gridview. but i don't know how many columns i need to display. at run time only i will come to know how many columns i need to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
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...
1
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...
0
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
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,...
0
jinu1996
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.