Page 1 of 1

System.Environment.NewLine???

Posted: Wed Jul 21, 2010 3:46 am
by jjc
Hi all ,
i need to store a field from th Database that get data in multiline with a line break and i use this code :

Code: Select all

if (CheckedListBoxControl3.Control.CheckedItems.Count >= 0)
{

for (int i=0; i<CheckedListBoxControl3.Control.CheckedItems.Count; i++)
{
string vari = CheckedListBoxControl3.Control.CheckedItems[i].ToString();

Excursion_TBL.First();

	while (!Excursion_TBL.IsEof)
   
{
   
switch(vari){
           case ("FD PHNOM PENH" + System.Environment.NewLine + "Full-day visit of Phnom Penh, the capital of Cambodia. Visit the National Museum, a beautiful collection of Khmer art masterpieces, world known for its sculptures and visit The Royal Palace, with it’s royal room, where the King still meets his guests and admire the Silver Pagoda. Visit of the Ounlom Pagoda and Tuol Sleng, which was an old prison during the Pol Pot regime and admire Wat Phnom hill located in the city centre and topped by a Buddhist temple.  Shopping at the Russian market."):
			  chkClassicColonialCAM.Checked = true;
			 break;}

	Excursion_TBL.Next();
		}
	}
}
when i compile the report i receive this error : error CS1010: Newline in constant .

it is the field i need to retrieve from the database:
FD PHNOM PENH
Full-day visit of Phnom Penh, the capital of Cambodia. Visit the National Museum, a beautiful collection of Khmer art masterpieces, world known for its sculptures and visit The Royal Palace, with it’s royal room, where the King still meets his guests and admire the Silver Pagoda. Visit of the Ounlom Pagoda and Tuol Sleng, which was an old prison during the Pol Pot regime and admire Wat Phnom hill located in the city centre and topped by a Buddhist temple. Shopping at the Russian market.
I ask why i cannot retrieve this field with the code i wrote down?DO i wrong using System.Environment.NewLine ?
Thansk so much for your attention.

Have a good day.

Cheers


System.Environment.NewLine???

Posted: Wed Jul 21, 2010 5:25 am
by Andrew
Hello,

This is a limitation of C#: in "case" operator only constants can be used.
The System.Environment.NewLine property is a variable, so expression is not a constant.

In you case it is enough for you to use the "if" operator.

Thank you.