473,796 Members | 2,702 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Equivalent of _ used in VB as concatenating code statement

Hi I want to construct a long string in C# in multiple lines therefore I
need a symbol to concatenate each line to the next line till the end of the
string.

In VB, there's a symbol "_" can be used at the end of each line. So what is
the equivalent in C#?

I don't like use "+" to separate a long string into multiple short ones
since it incurrs more double quotes.

Thanks in advance

-Richard
Nov 15 '05 #1
5 4660
Richard Chen wrote:
In VB, there's a symbol "_" can be used at the end of each line.
That's for long lines of code, not long strings.
So what is the equivalent in C#?
There is no counterpart since a line doesn't end until a smicolon is
encountered. Just press Enter.
I don't like use "+" to separate a long string into multiple short
ones since it incurrs more double quotes.


You have no choice as a string cannot include a hard return unless it's
a character (i.e. "\n").

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
Nov 15 '05 #2
Well, the only way I know of is using + which has the same meaning for
separate parts of a string or separate parts of any other stuff. Remember
a command is terminated with ; in C# so it can span many lines.

String line = "blah blah "
+ "some more blah "
+ Int32.Parse("1" )
+ "\n";

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Nov 15 '05 #3
And of course, you COULD always use a StringBuilder

"Morten Wennevik" <Mo************ @hotmail.com> wrote in message
news:opr0bth7lk hntkfz@localhos t...
Well, the only way I know of is using + which has the same meaning for
separate parts of a string or separate parts of any other stuff. Remember
a command is terminated with ; in C# so it can span many lines.

String line = "blah blah "
+ "some more blah "
+ Int32.Parse("1" )
+ "\n";

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Nov 15 '05 #4
Frank Oquendo <fr****@acadxpi n.com> wrote:
I don't like use "+" to separate a long string into multiple short
ones since it incurrs more double quotes.


You have no choice as a string cannot include a hard return unless it's
a character (i.e. "\n").


Not quite - if you are happy for the string itself to include the
return, you can use verbatim literals:

using System;

public class Test
{
static void Main(string[] args)
{
string x = @"hello
there";
Console.WriteLi ne (x);
}
}

I don't think I'd really recommend it though...

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #5
Thanks! That's what I want!

Thanks for all the other posts!

Cheers/Richard
"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
Frank Oquendo <fr****@acadxpi n.com> wrote:
I don't like use "+" to separate a long string into multiple short
ones since it incurrs more double quotes.


You have no choice as a string cannot include a hard return unless it's
a character (i.e. "\n").


Not quite - if you are happy for the string itself to include the
return, you can use verbatim literals:

using System;

public class Test
{
static void Main(string[] args)
{
string x = @"hello
there";
Console.WriteLi ne (x);
}
}

I don't think I'd really recommend it though...

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

Nov 15 '05 #6

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

Similar topics

4
15007
by: Gregory W. Ernest | last post by:
I am new to Java programming and I was wondering if anyone can tell me the java equivalent to a cin>>...; that is normally used in c++. I want to get user input and automatically assign it to a variable. So in other words what would be the equivant java statement of this c++ statement: 1: cout<<"Enter a number."; 2: cin>>x; //This is what I really want to know. I already know the java equivalent of the first statement.
16
3073
by: Dixie | last post by:
I have a problem using Dev Ashish's excellent module to concatenate the results of a field from several records into one record. I am using the code to concatenate certain awards onto a certificate at the end of the year. I have the code working fine, except for the fact that when I want to restrict the entries to awards between certain dates, even though I can use the restriction in the query that shows the actual records, when the...
4
12357
by: Scott Johnson | last post by:
Hi I am converting some code from C# to VB.NET and I have come across a command that I can't find the VB equivalent. The C# command is 'lock' and I think it is used to lock a data type from being used by other threads until it is released. (?) Here is the example: lock(typeof(className))
14
2556
by: grid | last post by:
Hi, I have a certain situation where a particular piece of code works on a particular compiler but fails on another proprietary compiler.It seems to have been fixed but I just want to confirm if both statements are similar : *((char **)v)++ == *((char **)v++) Where v is a pointer to an array of characters,defined as char *v;
6
2026
by: Jon Paal | last post by:
what is vb equiv. of ++ shown in C# ?
21
49055
by: clintonG | last post by:
Will somebody convert this for me... System.Web.UI.HtmlControls.HtmlHead header; header = TryCast(this.Page.Header, System.Web.UI.HtmlControls.HtmlHead); <%= Clinton Gallagher NET csgallagher AT metromilwaukee.com URL http://clintongallagher.metromilwaukee.com/ MAP http://wikimapia.org/#y=43038073&x=-88043838&z=17&l=0&m=h
7
2786
by: Mary | last post by:
I have a student who has a hyphenated first name. If I concatenate the name like this: StudentName:( & ", " & ), it works as expected. If, however, I try to get the first name first by concatenating like this: StudentName: ( & " " & ), only the first name appears. I sure would appreciate any help! Mary
10
3521
by: Neil | last post by:
Using the MS Rich Textbox Control 6.0 in Access 2000, I need to concatenate several RTB controls into a single RTF file. Sometimes two strings will be side-by-side; other times they need to be separated by a hard return. For example, say I have the following 4 RTB controls in my form: RTB1 = "abcd" RTB2 = "efgh" RTB3 = "ijkl" RTB4 = "mnop"
4
3890
by: laurenquantrell | last post by:
Is there an equivalant construction to the CASE WHEN statement that can be used in the WHERE clause? For example, this works: SELECT FirstName = CASE WHEN c.FirstName = 'Bob' THEN 'Robert' ELSE c.FirstName
0
9673
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10449
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10217
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10168
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9047
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6785
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5440
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.