|
It assumes that you were wrong as it may not come 2 httpS in the url,
you may resolve this by sending it as a query string ,if you own this site.
|
|
|
|
|
|
string aa = "\document\test";
aa = aa.Replace("\", "\\"); --- this line C# doesn't like it??
I want to replace '\' in string aa to "\\". How to do it?
|
|
|
|
|
You have to escape your chars
Alex Korchemniy
|
|
|
|
|
I suspect the problem is that \d and \t are valid escape values, so you've not realised the problem. To put a \ in your string, either put two or, ( my preferred option ), use @. With @ at the start, everything is literal, the only escape is double quotes to do quotes.
string aa = "\document\test";
The value here is ocument test, where the spaces are a tab
string aa = @"\document\test";
string aa = "\\document\\test";
These both set the string as you'd expect
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
If you have it already and want it to be replaced now,you may use the StringBuilder class that will assure that it's been replaced.
|
|
|
|
|
string aa = @"\document\test";
aa = aa.Replace(@"\", @"\\") ;
Sanjay Sansanwal
www.sansanwal.com
|
|
|
|
|
<br />
string aa = @"\document\test";<br />
<br />
aa = aa.Replace("\\", "\\\\");<br />
<br />
aa = aa.Replace(@"\", @"\\");<br />
<br />
<br />
Trick:
If U want to use \ in strings U must duplicate it, or use @ before teh string.
I hope it helps.
Nemo
|
|
|
|
|
Yeah so I created a nice little Web Service that returned a custom class called Site which has 3 strings and an int. I kept getting:
System.InvalidOperationException: There was an error generating the XML document. ---> System.InvalidOperationException: The type PortalService.Site was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically.
at System.Xml.Serialization.XmlSerializationWriter.WriteTypedPrimitive(String name, String ns, Object o, Boolean xsiType)
And I used both XmlInclude and SoapInclude to no avail. So I said screw it and created a string with a delimiter that I could parse when it returned to the client. Perfect. Except now when I call the WebService, the webpage's graphics don't load completely and at random. I suppose this perhaps attributed to the fact that I just did <% Function() %> since the basic Repeater did not suite my needs. Any suggestions?
|
|
|
|
|
I get a compiler error that not all code paths return an error. I'm fairly new at C# so did something change from MFC to C#?
<br />
public bool ConfirmSQLServer()<br />
{<br />
String SrvrName;<br />
SQLutilz sie = new SQLutilz();<br />
<br />
IniFile ini = new IniFile("C:\\Larimore\\Prog\\LA.CFG");<br />
SrvrName = ini.IniReadValue("DATABASE","Server");<br />
ResultsLst.Items.Add("Database Server: " + SrvrName, 0);<br />
String[] SrvrLst = sie.EnumerateSQLServers();<br />
<br />
for (int i = 0; i<SrvrLst.Length;i++)<br />
{<br />
MessageBox.Show(SrvrLst[i].ToString()+ " " + SrvrName.ToUpper());<br />
if (SrvrName.ToUpper().CompareTo(SrvrLst[i].ToString())== 0)<br />
return true;<br />
else<br />
return false;<br />
}<br />
}<br />
<br />
<br />
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Take your return statements out of the for loop.
Example)
bool retValue = false;<br />
for (int i = 0; i {<br />
MessageBox.Show(SrvrLst[i].ToString()+ " " + SrvrName.ToUpper());<br />
if (SrvrName.ToUpper().CompareTo(SrvrLst[i].ToString())== 0)<br />
retValue = true;<br />
break;<br />
}<br />
return retValue;
Eddie
|
|
|
|
|
C# sucks at working out that all code paths do indeed return a value, although in this case, you'll return no matter what on the first iteration.
You should set a return variable with a default value, and return it at the end, change it on the way through if need be. For example, I'd set a bool value to indicate success to false, and reset it to true only when everything had worked as expected.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian Graus wrote:
C# sucks at working out that all code paths do indeed return a value
Hmmm... I always had the feeling C# was rather clever doing this. Why exactly do you think C# 'sucks' in this point?
|
|
|
|
|
An example that hit me recently was when I was trying to use an if-elseif construct to return a different result for each value of an enum type. despite having a branch with a return for each possible value c# refused to accept that it always would return a value.
|
|
|
|
|
To be honest, I would think it would be more efficient to code it like I have. No memory is taken up by a BOOL in my code that you would in the earlier suggestion.
Thanks for all the help guys. Some things C# is really good at, other things it's not.
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Because I've written code where all paths return a value, but they are all in an if/else situation, and the compiler has barfed.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
hi all
anybody can help me to create a text file in c#?
thanks
|
|
|
|
|
Look in the System.IO namespace for lots of classes for reading and writing files.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
<br />
string fn="c:\texfile.txt";<br />
System.IO.StreamWriter sw=new System.IO.StreamWriter(fn,false,System.Text.Encoding.Default);<br />
<br />
sw.WriteLine("Tis is a line in the text file!");<br />
<br />
sw.Write("This text placed to the currnt file pointer place in the textfile");<br />
<br />
sw.Close();<br />
It's quite simply enjoy!
Nemo
|
|
|
|
|
Hi,
In my windows form, I have a set of CheckBoxes, which I am storing the selection as an integer value in the database and I am able to do that with CheckBoxes. But I have a groupBox with two radioButtons, I don't know how to read the bit values from it.
This is my GUI class....
CheckBox1.Checked = r.cSthA; //gets and sets the value for the
// checbox by reading the property
// from the class "r" given below.
// This is a different class
private enum rc : int
{
cSthA = 0x0001
};
public int Rac = 0;
public bool cSthA
{
get { return ((Rac & (int) rc.cSthA) != 0); }
set
{
if (value) Rac |= (int) rc.cSthA;
else Rac &= ~(int)rc.cSthA;
}
}
// How to set the property and read it for a groupBox.
I really appreciate ur help..
Thanks
|
|
|
|
|
Loop through radio buttons and check which are ticked
Sanjay Sansanwal
www.sansanwal.com
|
|
|
|
|
png file has got multilevel property.
I need to load a multilevel png file in separate bitmap (within my application).
How can i do?
|
|
|
|
|
If I populate a combo box manually with items, I can get the selected item using
comboBox.SelectedItem.ToString();
But now I have created a databound combobox, but cannot find out how to get its selected value.
comboBox.SelectedItem.ToString();
Returns System.Data.DataRow
and
comboBox.SelectedText.ToString()
returns "". Even though a value is selected.
How can I get the selected text/value of a datbound comboBox??
|
|
|
|
|
Well. Whats the problem here??
comboBox.SelectedItem contains the DataRow ... just use it.
Alex Korchemniy
|
|
|
|
|
Does anyone know where I can find information on how LIMS are designed? Specifically I'm wondering how a user of a LIMS system can define Materials to test and test methods / results and the program store data correctly for each result type. The front end will be written in C#.
Here's an example of what I need to do:
I have a material id as Liquid 7 which we test regularly. The tests include maybe a moisture (float data type) and a solids (float).
Now we are getting a new material Liquid 9 with tests moisture, solids and Pass. Moisture and solids are the same as for Liquid 7, but Pass is a string based off a visual check of the liquid.
I don't want to manually create a new database table for each new raw material we receive and test. I want an end user to define the test name and test result type and my program somehow store this data in a database for retrieval and analysis.
I don't know how commercial LIMS implement this but if anyone has any ideas I could use them.
|
|
|
|