I am running a thread in C#.
I have web form. I declared public string attribute in my web form. (e.g. string myVal)
Then I called thread and assign value into myVal.
It assign values in it.
But when I exit from thread code, myVal become null.
Is there anyway to keep myVal value.
public string myVal;
protected void Page_Load(object se...
Hi all,
I asked a similar question a couple of days ago, but I'm looking for more insight. I'm getting an AccessViolationException when I add a string to my program:
Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at _cexit(...
I have a string in the format: 'nn.nnnnn' in Python, and I'd like to convert it to an integer.
Direct conversion fails:
>>> s = '23.45678'
>>> i = int(s)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: '23.45678'
I can convert it to a decimal by using:
>>> ...
I have a very large number of app to convert to Delphi 2009 and there are a number of external interfaces that return pAnsiChars. Does anyone have a quick and simple way to cast these back to pChars? There is a lot on string to pAnsiChar, but much I can find on the other way around.
...
I want to compare the first few bytes in byte[] with a string. How can i do this?
...
Hello,
I am writing a simple program, which is trying to find next palindrome number after given number.
As for now, I am stuck at this point:
string::iterator iter; // iterators for the string
string::iterator riter;
//testcases is a vector<string> with strings representing numbers.
for (unsigned int i = 0; i < testcases.size() ; ...
I know that "string" in C# is a reference type. This is on MSDN. However, this code doesn't work as it should then:
class Test
{
public static void Main()
{
string test = "before passing";
Console.WriteLine(test);
TestI(test);
Console.WriteLine(test);
}
public static void TestI(string t...
Given a string that isn't too long, what is the best way to read it line by line?
I know you can do:
BufferedReader reader = new BufferedReader(new StringReader(<string>));
reader.readLine();
Another way would be to take the substring on the eol:
final String eol = System.getProperty("line.separator");
output = output.substring(outp...
I'd like the quickest way (in excel VBA) to identify whether one string occurs anywhere within another - an 'includes' function perhaps?
...
Is there an easy way to create a multiline string literal in C#?
Here's what I have now:
string query = "SELECT foo, bar"
+ " FROM table"
+ " WHERE id = 42";
I know PHP has
<<<BLOCK
BLOCK;
Does C# have something similar?
...
I'm sorry for flaming std::string and std::wstring. They are quite limited and far from being thread safe. Performance wise, they are not that good too. I miss simple features:
Splitting a string into array/vector/list
Simple & intuitive case-insensitive find & replace
Support for i18n without worrying about string or wstring
Conversi...
How can I break a long one liner string in my code and keep the string indented with the rest of the code? PEP 8 doesn't have any example for this case.
Correct ouptut but strangely indented:
if True:
print "long test long test long test long test long \
test long test long test long test long test long test"
>>> long test long te...
I have a regular expression to match anything between { and } in my string.
"/{.*}/"
Couldn't be simpler. The problem arises when I have a single line with multiple matches. So if I have a line like this:
this is my {string}, it doesn't {work} correctly
The regex will match
{string}, it doesn't {work}
rather than
...
I have this method for grabbing the file name from a string URI. What can I do to make it more robust?
private string GetFileName(string hrefLink)
{
string[] parts = hrefLink.Split('/');
string fileName = "";
if (parts.Length > 0)
fileName = parts[parts.Length - 1];
else
fileName = hrefLink;
return ...
I don't know how many countless times I've had to write code to validate string arguments:
public RoomName(string name)
{
if (string.IsNullOrEmpty(name))
{
throw new ArgumentException("Cannot be empty", "name");
}
}
Is there anyway to avoid this? Is there some attribute or design-by-contract mechanism to avoid this? I...
I used to generate random string in the following way (now I've switched to this method).
key = '%016x' % random.getrandbits(128)
The key generated this way is most often a 32 character string, but once I've got 31 chars.
This is what I don't get: why it's 32 chars, not 16? Doesn't one hex digit take one character to print?
So if I...
(IBAction) changeProductText:(NSString *)str;{
lblProductTxt.text = str;
}
I have that and i am trying to make it so that i can have the str and @"text" but i don't know how to bind them together.
Any thoughts?
...
I have a class named Car with property Name. Now every time I like to change Name of my Car I must write Car1.Name = "Porka Turbo". Now what I would like to acomplish is 5 characters less to write like this:
Car1 = "Porka Turbo"
It should work like this: if I assign a class derrived from Car class it should make regular class assignme...
What is the best rewrite of this method to speed it up?
public static bool EndsWith(string line, string term)
{
bool rb = false;
int lengthOfTerm = term.Length;
string endOfString = StringHelpers.RightString(line, lengthOfTerm);
if (StringHelpers.AreEqual(term, endOfString))
{
return true;
}
else
...
I have a string like this
field1=1 field2=2 field3=abc
I want to ouput this as
2,1,abc
Any ideas as to how I can go about this? I can write a small C or Java program to do this, trying I'm trying to find out a simple way to do it in Perl.
...