473,378 Members | 1,152 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,378 software developers and data experts.

String and variables

Hi,

For an message with variable values I'm using a string.

Like this:
string message = "Hi " + name + ",\n\n Here is your new password: " +
password;

Is there a way to do it like this:
string message = "Hi v1,\n\n Here is your new password: v2", name, password;

Hope that sombody knows what I want.

Thanks!
Nov 17 '05 #1
8 1136
Hi Arjen,

string name = "george";

String.Format("hello {0}", name );
Bye,

Ward

Arjen wrote:
Hi,

For an message with variable values I'm using a string.

Like this:
string message = "Hi " + name + ",\n\n Here is your new password: " +
password;

Is there a way to do it like this:
string message = "Hi v1,\n\n Here is your new password: v2", name, password;

Hope that sombody knows what I want.

Thanks!

Nov 17 '05 #2
Use string.Format
In ur case it will be,
string message = String.Format("Hi {0},\n\n Here is your new password: {1}",
name, password);
"Arjen" wrote:
Hi,

For an message with variable values I'm using a string.

Like this:
string message = "Hi " + name + ",\n\n Here is your new password: " +
password;

Is there a way to do it like this:
string message = "Hi v1,\n\n Here is your new password: v2", name, password;

Hope that sombody knows what I want.

Thanks!

Nov 17 '05 #3
Thanks!
"wbekker" <w.bekker@REMOVEequanimityTHISdotnl> schreef in bericht
news:43***********************@news.xs4all.nl...
Hi Arjen,

string name = "george";

String.Format("hello {0}", name );
Bye,

Ward

Arjen wrote:
Hi,

For an message with variable values I'm using a string.

Like this:
string message = "Hi " + name + ",\n\n Here is your new password: " +
password;

Is there a way to do it like this:
string message = "Hi v1,\n\n Here is your new password: v2", name,
password;

Hope that sombody knows what I want.

Thanks!

Nov 17 '05 #4
Hello,
another thing, I prefer writing Environment.NewLine instead of \n.

Maqsood Ahmed [MCP C#,SQL Server]
Kolachi Advanced Technologies
http://www.kolachi.net

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #5
Maqsood Ahmed <ma***********@gmail.com> wrote:
another thing, I prefer writing Environment.NewLine instead of \n.


That entirely depends on the situation. If you're communicating using a
protocol which specifies which line termination to use, you should use
that directly.

Environment.NewLine is fine for the default line terminator for the
current system, but that doesn't mean it's right for everything.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #6
What's the best for a text-based e-mail message?
(Using Environment.NewLine or \n)
Thanks!

"Jon Skeet [C# MVP]" <sk***@pobox.com> schreef in bericht
news:MP************************@msnews.microsoft.c om...
Maqsood Ahmed <ma***********@gmail.com> wrote:
another thing, I prefer writing Environment.NewLine instead of \n.


That entirely depends on the situation. If you're communicating using a
protocol which specifies which line termination to use, you should use
that directly.

Environment.NewLine is fine for the default line terminator for the
current system, but that doesn't mean it's right for everything.

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

Nov 17 '05 #7
Arjen <bo*****@hotmail.com> wrote:
What's the best for a text-based e-mail message?
(Using Environment.NewLine or \n)


Well, what are you submitting the email to? I would suggest using \r\n
for email, as that's what RFC 822 uses for line termination - not
Environment.NewLine, as that's not guaranteed to be \r\n on all
platforms.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #8
Okay, thanks!

Arjen
"Jon Skeet [C# MVP]" <sk***@pobox.com> schreef in bericht
news:MP***********************@msnews.microsoft.co m...
Arjen <bo*****@hotmail.com> wrote:
What's the best for a text-based e-mail message?
(Using Environment.NewLine or \n)


Well, what are you submitting the email to? I would suggest using \r\n
for email, as that's what RFC 822 uses for line termination - not
Environment.NewLine, as that's not guaranteed to be \r\n on all
platforms.

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

Nov 17 '05 #9

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

Similar topics

12
by: Eli Daniel | last post by:
Hi, I'm new to Python. Can you please tell me if the following is possible. My users are using other scripting launguage to write scripts. They are used to write somthing like (keeping it...
14
by: brad | last post by:
I've got a multithreaded application using std::string in Linux. Performance is not very good so I ran Quantify(tm) to look at what is happening. Most of the time my app was calling...
5
by: David Rasmussen | last post by:
If I have a string that contains the name of a function, can I call it? As in: def someFunction(): print "Hello" s = "someFunction" s() # I know this is wrong, but you get the idea... ...
32
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if...
10
by: ksrajalakshmi | last post by:
Hai , in a textbox am having text as "(20/100)+pay1*pay2" .it's a formula. and stored in a particular variable. string strformula="(20/100)+pay1*pay2" ; i've to substitute the value of the...
5
by: Chris H | last post by:
Okay, I am trying to us a varialble with a list of number values as my data for an array, yet when I do this it doesnt return any values from the array, i was able to temporarily fix the proble by...
7
by: Andy C Matthews | last post by:
Hi there, I'm building an Access database and using VBA to generate Microsoft Word mailings for customers. It's all going fine so far. However, a variables named ParcelID, a ten-digit string such...
2
by: comp.lang.php | last post by:
I am trying to replace within the HTML string $html the following: With Where I'm replacing "action=move_image" with "action=<?= $_REQUEST ?>"
11
by: RipperT | last post by:
Don't know if this group covers web apps, but here goes. In VS 2005, I am trying to get variables to hold thier values during postback from the server. I convert a text box's user-keyed value to an...
1
by: kellysgirl | last post by:
Now what you are going to see posted here is both the set of instructions I was given..and the code I have written. The instructions I was given are as follows In this case, you will create...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
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,...
0
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...
0
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.