For example to get local ip address I use:
string myHost = System.Net.Dns.GetHostName();
string myIP = System.Net.Dns.GetHostEntry(myHost).AddressList[0].ToString();
How would you convert an arbitrary string into a unique integer, which would be the same across Python sessions and platforms? For example hash('my string') wouldn't work because a different value is returned for each Python session and platform.
I'm trying to have method void run( string method ) which would run method in that class. For example:
class Foo {
public:
void run( string method ) {
// this method calls method *method* from this class
}
void bar() {
printf( "Function bar\n" );
}
void foo2() {
printf( "Function foo2\n" );
}
}
Foo foo;
int main( void ) {
foo.run( "bar" );
foo.run( "foo2" );
}
this would print:
Function bar
Function foo2
Thanks! :)
I am receiving a BASE64 encoded string from a WebService. The string represents an HTML page, and I can use built-in ColdFusion functions to convert and display it. However, I need a GIF representation of the HTML page, and I'm wondering if there's any way to do this using ColdFusion.
i am passing the textbox1.text values into a query and sometimes into a string
sometimes i say this:
dim combor1 as string
combor1 = comboReason1.Text
how do i know when i should put combor1=comboreason1.value ??
also why do i need to set focus for a control to reference its property? that doesn't make sense to me
also when i set combor4 = comboReason4.Value and the .value is null, then i get an error about invalid use of null
please help!
I have a string of letters and I want to search it for a specific letter.
NSString *word = @"word";
How would I find out if the string contained a letter "w"?
Thanks
Lets says I have the following model
public class Person
{
[NameIsValid]
public string Name { get; set;}
public string LastName { get; set; }
}
I created a custom attribute NameIsValid for this model. Lets says for ViewA I need the custom attribute validation in the model, but for ViewB I dont need this custom validation attribute, how can I dinamically set or remove the custom attribute from the model when need it?
Thanks!
I need to use a class callback method on an array inside another method (the callback function belongs to the class).
class Database {
public function escape_string_for_db($string){
return mysql_real_escape_string($string);
}
public function escape_all_array($array){
return array_filter($array,"$this->escape_string_for_db");
}
}
Is this the right way to go about that? (I mean, in terms of the second parameter passed to array_filter)
Consider this function declaration:
int IndexOf(const char *, char);
where char * is a string and char the character to find within the string (returns -1 if the char is not found, otherwise its position). Does it make sense to make the char also const? I always try to use const on pointer parameters but when something is called by value, I normally leave the const away.
What are your thoughts?
I saw the following namespace implementation in an article and i really can't get the point why they did so?
using sysConfig =System.Configuration ;
string connectionString = sysConfig.ConfigurationManager.
ConnectionStrings["connectionString"].ConnectionString;
I know It can be easily implemented like this,
string connectionString = System.Configuration.ConfigurationManager.
ConnectionStrings["connectionString"].ConnectionString;
Any suggestion when to use the first type...
What does that mean ?
public bool? Verbose { get; set; }
When applied to string? , there is an error
Error 11 The type 'string' must be a non-nullable value type in order to use it as parameter 'T' in the generic type or method 'System.Nullable'
Hi
How do I change my code so that it lists the elements in alphabetical order from a to z. Right now it's ordering from z to a. I can't figure it out and am stuck :-/
String sName1 = ((Address)o).getSurname().toLowerCase();
String sName2 = (this.surname).toLowerCase();
int result = (sName1).compareTo(sName2);
return result;
Thanks :)
I want to create an array of all the html elements within a div that contain text strings, such as
<p>some string</p>.
I don't want to get hold of the strings, I want the array items to be the elements (in the example, would be the p node). I do not know before hand what the strings will be, so I can't look for string values to match. I also don't want empty text nodes to end up in the array.
Thanks!
I'm rubbish at Regular Expressions, really!
What I'd like is to split a string containing a CCS property value into an array of [string,value,unit].
For example: if I supplied the .split() method with 1px it'd return ["1px",1,"px"]. If I were to supply, similarly, 10% it'd return ["10%",10,"%"].
Can this be done?
I appreciate all your help!
I am trying to pass a string to an asmx service. Actually, the parameter is a number with leading zeros, but the asmx gets the string with leading zeros removed.
How to avoid the truncation of leading zeros.
TIA.
How can I validate a String null or empty using the c tags of JSLT.
I have a variable of name var1 and I can display it, but I want to add a comparator for validate it.
I want to validate when is different of null or empty (my values are string).
I am using g_object_set_data to set user name with event_box so in call back i can get it with in event_box pointer.
g_object_set_data(G_OBJECT(event_box), "user_name", (gpointer)(user_name) );
but problem is that i am setting user_name which is not an pointer allocated string.
It is an local string (not allocated on hip) which gets destroyed.
So is it necessary to allocated and then use the pointer, i just want to associate one name with this event_box.
Can someone help me understand advantages and disadvantages (if any) between the following methods which do the same function of storing away the entity to azure (in my case)?
public bool Save<T>(string tableName, T entity) where T : TableEntityBase, new()
{
throw new NotImplementedException();
}
vs
public bool Save(string tableName, TableEntityBase entity)
{
throw new NotImplementedException();
}
I am attempting to write a regular expression to process a string of key value(s) pairs formatted like so
KEY/VALUE KEY/VALUE VALUE KEY/VALUE
A key can have multiple values separated by a space.
I want to match a keys values together, so the result on the above string would be
VALUE
VALUE VALUE
VALUE
I currently have the following as my regex
[A-Z0-9]+/([A-Z0-9 ]+)(?:(?!^[A-Z0-9]+/))
but this returns
VALUE KEY
as the first result.
I have a json response coming and i need to get all the values whose keys are a particular string... for e.g : www_name, www_age etc are coming in the nsmutabledictionary as keys now i want to search all those values having "www_" as their part of the string.
Consider this piece of code:
public abstract class Validator
{
protected Validator()
{
}
protected abstract void ValidateCore(object instance, string value, IList<ValidationResult> results);
public void Validate(object instance, string value, IList<ValidationResult> results)
{
if (null == instance) throw new ArgumentNullException("instance");
if (null == results) throw new ArgumentNullException("results");
ValidateCore(instance, value, results);
}
}
Look at the Validate() overload, how can an abstract class have definitions like this?
I am checking login of a user by this repository method,
public bool getLoginStatus(string emailId, string password)
{
var query = from r in taxidb.Registrations
where (r.EmailId == emailId && r.Password==password)
select r;
if (query.Count() != 0)
{
return true;
}
return false;
}
I saw in one of the previous questions !query.Any() would be faster... Which should i use? Any suggestion....
I've got a Dictionary<string, string> and would like to have the user to see and edit the content, possibly adding new entries. How should I do that?
Input verification, handling dynamic updates of the source Dictionary and looking nice are a bonus.
The docs about openssl_sign() say that the signature is returned in the passed string argument. My question is - how is it encoded? Base64, Hex-string, anything else?
I don't have php installed and I have to use this PHP code I was given simply in order to verify whether my Java implementation is correct, so don't ask me "have you tried it" ;)
Hi,
I have converted my NSString into string, and returning the same but the above error mentioned in the title is printing on console. Please suggest so that i could get away from this issue.
my code is below:
string stringFromNSString(NSString *inNSString)
{
return [inNSString UTF8String];
}