Possible Duplicate:
string.IsNullOrEmpty() vs string.NotNullOrEmpty()
Can someone explain to me why in .NET I would write String.IsNullOrEmpty(str) instead of str.IsNullOrEmpty()? There must be a logical reason but I don't know it.
It sounds like you guys are saying
You can't call methods from objects that are null in C#/.NET...
i have a URL lets say .
some time i need to send HTTP and some time i need to send it to HTTPS
for that i created a enum:
Private _protocol As Protocol
Enum Protocol
HTTP
HTTPS
End Enum
Public Property protocolType() As Protocol
Get
Return _protocol
End Get
Set(ByVal value As Protocol)
_protocol = v...
I have the following python 3 file:
import base64
import xxx
str = xxx.GetString()
str2 = base64.b64encode(str.encode())
str3 = str2.decode()
print str3
xxx is a module exported by some C++ code. This script does not work because calling Py_InitModule on this script returns NULL. The weird thing is if I create a stub xxx.py in the sa...
Hi,
I want to add a new (fstream) function in a program that already uses char arrays to process strings.
The problem is that the below code yields strings, and the only way i can think of getting this to work would be to have an intermediary function that would copy the strings, char by char, into a new char array, pass these on to the...
Hi All,
I am trying to persist string from an ASP.NET textarea. I need to strip out the carriage return line feeds and then break up whatever's left into a string array of 50 character pieces.
I have this so far
var commentTxt = new string[] { };
var cmtTb = GridView1.Rows[rowIndex].FindControl("txtComments") as TextBox;
if (cmtTb != n...
I thought I'd be classy and use the string.xml file to define some constant strings for things like exception messages. In strings.xml I hit Add, chose the "String" option (not 'String Array'), then gave it a name and value. I was surprised to see that this code doesn't work:
throw new Exception(R.string.MyExceptionMessage);
And tha...
This is my function.
public Dictionary<string, string> ArrayToDictionaryConverter(object [] objArray)
{
string[] strArray = new string[objArray.Length];
strArray =(string[])objArray;
Dictionary<string, string> dictionary = null;
try
{
dictionary = new Dictionary<string, string>();...
Hi,
I'm not very familiar with locale-specific conversions so I may be using the wrong terminology here. This is what I want to have happen.
I want to write a function
std::string changeLocale( const std::string& str, const std::locale& loc )
such that if I call this function as follows:
changeLocale( std::string( "1.01" ), std::lo...
I have a some numbers stored in a Integer called mode, but I need to use they in a TProcess. For this I need to convert the Integer into a String, because if I don't do this, I got the error:
Incompatible types: got "LongInt" expected "AnsiString"
Then I want to know how I can convert a Integer into a String?
...
I looking for a function like regexp_split_to_table, but our db is version 8.2.9, so it doesn't have it. I'm really only splitting on a space, so a string like
how now brown cow
would return
+------+
|Column|
+------+
|how |
|now |
|brown |
|cow |
+------+
is there a simple function that can handle this, or something I ...
Ignore the reasons why someone would want to do this.... :)
I want to be able to take some bytes, covert them to a string, then later back to the same byte array. Same length and everything.
I've tried using the ASCIIEncoder class (works for only text files) and Unicode Encoder class (only works so far for arrays 1024*n big. I assume t...
How can i get the value of a UITextField?
Some sample code to attach it to an NSString would be fab!
P.S - Happy New Year!
...
i am having a problem with string comparison. For example, I have this string:
"hello world i am from heaven"
I want to search if this string contains "world". I used following functions but they have some problems. I used String.indexof() but if i will try to search for "w" it will say it exists.
In short i think i am looking for ex...
When writing file paths in C#, I found that I can either write something like "C:\" or "C:/" and get the same path. Which one is recommended? I heard somewhere that using a single / was more recommended than using \ (with \ as an escaped sequence).
...
Hi,
The following program does not work as I intended.
#include <string.h>
#include <stdio.h>
int main()
{
const char *c = "abcdef";
// prints 'f' as expected
printf("%c\n", c[5]);
// comparison fails, does not print "yes"
if (c[5] == 'f')
printf("yes");
return 0;
}
How can I compare a character in ...
PHP has a lot of trouble with multibyte strings (non-ASCII characters). The entire language was built assuming that each character is a byte. To solve this they invented the mb_strings functions which you can use instead of the standard functions (which work fine).
strlen($str);
mb_strlen($str); // correct
However, this is really a pa...
How can i convert String like 20100102 into datetime in a formate of dd/MM/yyyy?
...
It seems to me that the YAML library that ships with ruby 1.9 is encoding-deaf.
What this means is that when generating YAML, it'll take any string of bytes, and escape any byte sequence that doesn't output clean ASCII. That's lame, but acceptable.
My problem is the other way around. When loading content from said YAML dump.
In the ex...
Basically, I have 10 data files and I wrote a MATLAB function to process these data.
The code is like this:
function Z = fitdata(file_path)
A = importdata(file_path,',');
...
end
Since I don't want to input the same command 10 times (for different file names), I wrote another script to automate this processing. The code looks li...
Suppose that you have a lengthy string (> 80 characters) that you want to spread across multiple source lines, but don't want to include any newline characters.
One option is to concatenate substrings:
string longString = "Lorem ipsum dolor sit amet, consectetur adipisicing" +
" elit, sed do eiusmod tempor incididunt ut labore et d...