Search Results

Search found 35302 results on 1413 pages for 'string literals'.

Page 102/1413 | < Previous Page | 98 99 100 101 102 103 104 105 106 107 108 109  | Next Page >

  • Convert Null Value to String - C#.NET

    - by peace
    foreach (PropertyInfo PropertyItem in this.GetType().GetProperties()) { PropertyItem.SetValue(this, objDataTable.Rows[0][PropertyItem.Name.ToString()], null); } In one of the loops i get this exceptional error: Object of type 'System.DBNull' cannot be converted to type 'System.String'. The error occurs because one of the fields in the database has no value (null), so the string property could not handle it. How can i convert this null to string? I got this solution If you know a shorter or better one, feel free to post it. I'm trying to avoid checking on every loop is current value is null or not.

    Read the article

  • Is it a good idea to return " const char * " from a function?

    - by AJ
    Now I have a function that has to return a string. I saw a particular implementation where he returns a const char * from the function. Something like this: const char * GetSomeString() { ........ return somestlstring.c_str(); } SomeOtherFoo () { const char * tmp = GetSomeString(); string s = tmp; } Now I felt there is something potentially wrong with this. Is my gut feel right? or Is this a perfectly safe code? Kindly give me ur suggestions. I have a feeling return const char * this way might result in havoc.. Thanks, Arjun

    Read the article

  • Count How many lines in a Java String

    - by Simon Guo
    Need some compact code for counting how many lines in a string. It should be Java Code. And the string is separated by \r or \n will be considered as a separate line. For example, "Hello\nWorld\nThis\nIs\t" should return 4. The prototype is private static int countLines(String str) {...} Can someone provide a compact code? I have solution at here but it is too long, I think. Thank you.

    Read the article

  • Glib convert epoch time to string.

    - by PP
    I am using glibs functions to convert epoch time to string as follows. But each time it is giving me some random time. //Convert Time in string. GDate *date = g_date_new_julian(timestampsecs); gchar date_string[50]; g_date_strftime(date_string, 50, (const gchar*)"%a, %I:%M %p", (const GDate*)date); printf("Date String [%s]\n", date_string ); Why this might be happening? am i missing anything? Thanks, PP.

    Read the article

  • request payload versus query string parameters

    - by Sarah Sides
    I am absolutely in the dark when it comes to this request payload that I'm seeing in my Chrome browser. A Query string will have a variable attached like session:2g0SoEE but this payload has just one long string I'm guessing is in base64. I do understand that the request payload can have whatever, but how do I use it? Can I do a post with jquery and send this request payload? For example: $.post(url, {variable: "variable"}, function(data){}); When this posts it will send &variable=variable this will be found as query string parameter in the headers sent in chrome. In this game I'm playing I see another piece of info being sending in the header called a payload request. I'm a confused as to how this is read, used, made, how I can reduplicate this? Here is something similar: Chrome is caching an HTTP PUT request and How to retrieve Request Payload

    Read the article

  • WPF - Correct Syntax for Using Coverter with Current Binding

    - by Andy T
    Hi, I have a collection of hex strings that represent colours and I am binding a combobox's ItemsSource to that collection. The combobox items are templated to have a filled rectangle with the relevant colour. I therefore need to use a converter to convert the hex value to a string. Easy enough. However, Blend is telling me that this syntax is incorrect in my XAML: Fill="{Binding, Converter={StaticResource StringToBrush}}" Apparently, I can't use a converter against plain old 'Binding'. Blend says that something like this is syntactically correct: Fill="{Binding Value, Converter={StaticResource StringToBrush}}" ...However that obviously doesn't work. I'm not quite au fait with binding syntax yet, so obviously I'm getting it wrong. Can anyone advise the correct syntax to achieve what I'm trying to do (convert my bound String using the coverter StringToBrush)? Thanks in advance! AT

    Read the article

  • how to replace multi string with a array node in js

    - by Rueta
    hi everyone! i here a Work and i don't know how to do it. i have a string here: <div class="demotext"> <p>this is demo string i demo want to demo use</p> </div> i create the array variable for demo: var demoarray = new array('a','b','c'); now i want replace 'demo' in string by array node, follow 'demo' one change to 'a' , 'demo' two change to 'b'....

    Read the article

  • ColdFusion static key/value list?

    - by richardtallent
    I have a database table that is a dictionary of defined terms -- key, value. I want to load the dictionary in the application scope from the database, and keep it there for performance (it doesn't change). I gather this is probably some sort of "struct," but I'm extremely new to ColdFusion (helping out another team). Then, I'd like to do some simple string replacement on some strings being output to the browser, looping through the defined terms and replacing the terms with some HTML to define the terms (a hover or a link, details to be worked out later, not important). Can anyone point me in the right direction of: How to define the stucture (if that is what I need for a key/value pair list) How to query at the application start-up and reuse the list properly The best way to do the string replacement

    Read the article

  • Converting Negative Decimal To String Loses the -

    - by coffeeaddict
    I'm required to send in a negative myDecimalValue.ToString("C"); The problem is if myDecimalValue is a negative, lets say -39, after conversion I'm getting $39.00 as the string not $39.00. So I'm not sure how to go about this. This is the utility method that takes in the decimal. If the decimal is negative, I want the ToString to show a negative public static BasicAmountType CreateBasicAmount(string amount, CurrencyCodeType currencyType) { BasicAmountType basicAmount = new BasicAmountType { currencyID = currencyType, Value = amount }; return basicAmount; } I could go either way, a C or F2, all I care is about getting that negative sign intothe string if the incoming decimal is negative. I suppose there's no way to do this unless I check for negativity inside my utility method here. I can't just send a negative number and expect the ToString to work and for the ToSTring to automatically see that the decimal is negative incoming?

    Read the article

  • JavaScript - checking for any lowercase letters in a string

    - by pcampbell
    Consider a JavaScript method that needs to check whether a given string is in all uppercase letters. The input strings are people's names. The current algorithm is to check for any lowercase letters. var check1 = "Jack Spratt"; var check2 = "BARBARA FOO-BAR"; var check3 = "JASON D'WIDGET"; var isUpper1 = HasLowercaseCharacters(check1); var isUpper2 = HasLowercaseCharacters(check2); var isUpper3 = HasLowercaseCharacters(check3); function HasLowercaseCharacters(string input) { //pattern for finding whether any lowercase alpha characters exist var allLowercase; return allLowercase.test(input); } Is a regex the best way to go here? What pattern would you use to determine whether a string has any lower case alpha characters?

    Read the article

  • Convert String value format of YYYYMMDDHHMMSS to C# DateTime

    - by SARAVAN
    I have a need to convert a string value in the form "YYYYMMDDHHMMSS" to a DateTime. But not sure on how, may be a DateTime.Tryparse can be used to make this happen. Or is there any other way to do it. I can do this using some string operations to take "YYYYMMDD" alone, convert to a datetime and then add HH, MM, SS separately to that DateTime. But is there any DateTime.TryParse() methods that I can use in one line to convert a "YYYYMMDDHHMMSS" format string value to a DateTime value?

    Read the article

  • Using Regex to modify a String

    - by Christine Dehner
    I have a String that looks like this: Blah blah one.<tmp>[[url=b, link=c]]</tmp> Blah blah two. Also remember, blah blah three.<tmp>[[url=d, link=e]]</tmp> So I want to get b and d (the url attribute of tmp), and change the String so that it looks like this (the ex() function returns a String): Blah blah one.<tmp>[[url=b, link=c, add=ex(b)]]</tmp> Blah blah two. Also remember, blah blah three.<tmp>[[url=d, link=e, add=ex(d)]]</tmp> I need to use regex because no existing library parses this type of markup. I hope my explanation is clear. Thanks in advance!

    Read the article

  • Best way for saving infinit playlists (arrays) into db? (php mySql)

    - by Ole Jak
    So client gives me a string like "1,23,23,abc,ggg,544,tf4," from user 12 . There can be infinit number of elements with no spaces just value,value,... structure. I have users table (with users uId(key), names etc). I have streams table with ( sId(key), externalID, etc values). User sends me externalId's. And I need to hawe externalId's in play list (not my sId's). I need some way to store such array into my DB and be able to get it from DB. I need to be able to do 2 things return such string back to user be able to get na array from it like {1; 23; 23; abc; ggg; 544; tf4;} So what is best method (best here means shourt(small amount of) code) to store such data into db to retrivew stored tata in bouth ways shown

    Read the article

  • String to image only produces black background

    - by Phil Jackson
    Hi im really having a problem find how to fix this. $string = "foo"; $font = 4; $width = ImageFontWidth($font) * strlen($string); $height = ImageFontHeight($font); $im = @imagecreatetruecolor ($width,$height); $bg = imagecolorallocate($im, 255, 255, 255); $textcolor = imagecolorallocate($im, 0, 0, 0); imagestring($im, 5, 0, 0, $string, $textcolor); imagegif($im, 'somefile.gif', 8); imagedestroy($im); I cannot seem to change the background from black. Does anyone have any ideas?

    Read the article

  • How to convert List<int> to string[]?

    - by George Edison
    I need an easy way to convert a List<int> to a string array. I have: var the_list = new List<int>(); the_list.Add(1); the_list.Add(2); the_list.Add(3); string[] the_array = new string[the_list.Count]; for(var i = 0 ; i < the_array.Count; ++i) the_array[i] = the_list[i].ToString(); ...which looks to be very ugly to me. Is there an easier way? Note: I'm looking for an easier way - not necessarily a faster way.

    Read the article

  • Java - Need help with binary/code string manipulation

    - by ShrimpCrackers
    For a project, I have to convert a binary string into (an array of) bytes and write it out to a file in binary. Say that I have a sentence converted into a code string using a huffman encoding. For example, if the sentence was: "hello" h = 00 e = 01, l = 10, o = 11 Then the string representation would be 0001101011. How would I convert that into a byte? <-- If that question doesn't make sense it's because I know little about bits/byte bitwise shifting and all that has to do with manipulating 1's and 0's.

    Read the article

  • Parse a json(?) string using php

    - by passatgt
    I have a string, more specifically, this one: a:16:{s:9:"pseudonym";O:16:"SimpleXMLElement":0:{}s:14:"parallel_title";O:16:"SimpleXMLElement":0:{}s:9:"title_var";O:16:"SimpleXMLElement":0:{}s:6:"series";O:16:"SimpleXMLElement":0:{}s:9:"vol_title";O:16:"SimpleXMLElement":0:{}s:9:"reference";O:16:"SimpleXMLElement":0:{}s:10:"bound_with";O:16:"SimpleXMLElement":0:{}s:15:"general_remarks";O:16:"SimpleXMLElement":0:{}s:6:"copies";O:16:"SimpleXMLElement":1:{i:0;s:1:"1";}s:11:"remarks_BPH";O:16:"SimpleXMLElement":0:{}s:3:"ICN";O:16:"SimpleXMLElement":1:{i:0;s:4:"neen";}s:10:"provenance";O:16:"SimpleXMLElement":0:{}s:7:"binding";O:16:"SimpleXMLElement":0:{}s:10:"size_hxwxd";O:16:"SimpleXMLElement":0:{}s:6:"BookID";O:16:"SimpleXMLElement":1:{i:0;s:4:"6271";}s:5:"repro";O:16:"SimpleXMLElement":0:{}} Is it possible to parse this string somehow? I need to display the keys and values in a list. I tried to use json_decode but it not returns anything, even with the second true parameter(json_decode($string,true))

    Read the article

  • Regular Expression to return the contents of a HTML tag received as a string of text

    - by Nathan Hernandez
    I have a string in my code that I receive that contains some html tags. It is not part of the HTML page being displayed so I cannot grab the html tag contents using the DOM (i.e. document.getElementById('tag id').firstChild.data); So, for example within the string of text would appear a tag like this: 12 My question is how would I use a regular expression to access the '12' numeric digit in this example? This quantity could be any number of digits (i.e. it is not always a double digit). I have tried some regular expressions, but always end up getting the full span tag returned along with the contents. I only want the '12' in the example above, not the surrounding tag. The id of the tags will always be 'myQty' in the string of text I receive. Thanks in advance for any help!

    Read the article

  • How do I convert a NSString into TIS-620 encoded string

    - by MacPC
    In the apple document, I can see that there's a way to convert from UTF8 string to ASCII string like this NSData *asciiData = [theString dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; NSString *asciiString = [[NSString alloc] initWithData:asciiData encoding:NSASCIIStringEncoding]; But my app requires a TIS-620 string to post to a site so I try to do the same thing NSData *asciiData = [newPost.header dataUsingEncoding:kCFStringEncodingMacThai allowLossyConversion:YES]; NSString *asciiString = [[NSString alloc] initWithData:asciiData encoding:kCFStringEncodingMacThai]; NSLog(@"%@", asciiString); The output I got is like this ???????????. Does anyone know how to convert the NSString to TIS-620 properly? Thanks so much.

    Read the article

  • convert array of objects to concatenated string

    - by oo
    if i have: List<Car> where car is: public class Car { public int Year; public string Name; } and i want to take this array and create a concatenated string by "," so it would return: "Toyota", "Ford", "Chevy" i can do it manually like this: private static string CreateConcatenatedList(List<Car> parts_) { StringBuilder b = new StringBuilder(); foreach (Car bp in parts_) { b.Append(bp.Name + ", "); } b.Remove(b.Length - 2, 2); return b.ToString(); } but i thought there might be a more elegant way

    Read the article

  • find whether the string starts and ends with the same word

    - by Ajax
    I am trying to check whether the string starts and ends with the same word. egearth. s=raw_input(); m=re.search(r"^(earth).*(earth)$",s) if m is not None: print "found" my problem is when the string consists only of one word eg: earth At present I have hard coded this case by if m is not None or s=='earth': print "found" Is there any other way to do this? EDIT: words in a string are separated by spaces. looking for a regex solution some examples: "earth is earth" ,"earth", -- valid "earthearth", "eartheeearth", "earth earth mars" -- invalid

    Read the article

  • Problem with literal arguments in the PATTERN string for a python 2to3 fixer

    - by Zxaos
    Hi folks. I'm writing a fixer for the 2to3 tool in python. In my pattern string, I have a section where I'd like to match an empty string as an argument, or an empty unicode string. The relevant chunk of my pattern looks like: (args='""' | args='u""') My issue is the second option never matches. Even if it's alone, it won't match. However, if I simply say args=any and then output args, I can catch cases where args is exactly equal to the second option. Is there some weird unicode handling thing going on? Why won't the second literal option ever match?

    Read the article

< Previous Page | 98 99 100 101 102 103 104 105 106 107 108 109  | Next Page >