string

C# cast string to enum with enum attribute

Hello, i've got the following question: I've got public enum Als { [StringValue("Beantwoord")] Beantwoord = 0, [StringValue("Niet beantwoord")] NietBeantwoord = 1, [StringValue("Geselecteerd")] Geselecteerd = 2, [StringValue("Niet geselecteerd")] NietGeselecteerd = 3, } with public class Stri...

Index of arrays and strings in c++

I want to know from where the index of a string and an array starts from. I am getting a lot of confusion while making programs. While calculating string length of a string is the null character also counted? ...

string.replace seriously broken with \

"C://test/test/test.png" -> blub blub = blub.Replace(@"/", @"\"); result = "C:\\\\test\\test\\test.png" how does that make sense? It replaces a single / with two \ ? ...

ruby parametrized regular expression

I have a string like "{some|words|are|here}" or "{another|set|of|words}" So in general the string consists of an opening curly bracket,words delimited by a pipe and a closing curly bracket. What is the most efficient way to get the selected word of that string ? I would like do something like this: @my_string = "{this|is|a|test|case}...

How to asynchronously read to std::string using Boost::asio?

Hello. I'm learning Boost::asio and all that async stuff. How can I asynchronously read to variable user_ of type std::string? Boost::asio::buffer(user_) works only with async_write(), but not with async_read(). It works with vector, so what is the reason for it not to work with string? Is there another way to do that besides declaring c...

find string in DataGridView

I'm using a foreach loop to populate each row in a DataGridView with a string. I need to search the DataGridView to make sure that I don't add a string that is already there. What is the best way to do this? Here is my code so far: foreach (String file in openFileDialog.FileNames) { // to...

C++ exam question on string class implementation

I just took an exam where i was asked the following: Write the function body of each of the methods GenStrLen, InsertChar and StrReverse for the given code bellow. You must take into consideration the following; How strings are constructed in C++ The string must not overflow Insertion of character increases its length by ...

Javascript Getting a string into kb format

I am new to javascript and I just wanted to convert a string into a format that a person like me can read. Here is an example of what I am trying to do... string2size(string){ //some awesome coding I have no clue how to make return awesomeAnswer } now the return should give me something like 56 bytes or 12kb or 1mb depending how much...

C# null terminated string

I am communicating with a server who needs null terminated string How can I do this smartly in C#? ...

C++: Define simple constant for use?

In C++ I wanted to define a constant that I can use in another function, A short answer on how to do this will be fine.. Lets say at the beginning of my code I want to define this constant: //After #includes bool OS = 1; //1 = linux if (OS) { const ??? = "clear"; } else { const ??? = "cls"; } I don't know what type to use to def...

How to Convert Boolean to String

I have a boolean variable which I want to convert to a string $res = true; I need it the converted value to also be in the format "true" "false" not "0" "1" $converted_res = "true"; $converted_res = "false"; I've tried: $converted_res = string($res); $converted_res = String($res); but it tells me string and String are not recogn...

How to convert string with double high/wide characters to normal string [VC++6]

My application typically recieves a string in the following format: " Item $5.69 " Some contants I always expect: - the LENGHT always 20 characters - the start index of the text always [5] - and most importantly the index of the DECIMAL for the price always [14] In order to identify this string correctly I validate all the...

.each or search function, how can I make use of those?

I have a ul list, with 10 items, and I have a label that displays the selected li text. When I click a button, I need to check the label, versus all the list items to find the matching one, when it finds that I need to assign the corresponding number. I.e. list: Messi Cristiano Zlatan hidden values of list items: www.messi.com www.cr...

JavaScript: Given an offset and substring length in an HTML string, what is the parent node?

My current project requires locating an array of strings within an element's text content, then wrapping those matching strings in <a> elements using JavaScript (requirements simplified here for clarity). I need to avoid jQuery if at all possible - at least including the full library. For example, given this block of HTML: <div> <p>T...

string.EndsWith()

I need to check in string.Endswith("") from any of the following operators: "+,-,*,/" If I have 20 operators I don't want to use "||" operator 19 times. ...

Formatting a byte array to string in java

I am using this code to find the MAC address of a machine.This code prints directly the MAC address, but i want to return it as a string.I am completely confused. please help. try { InetAddress add = InetAddress.getByName("10.123.96.102"); NetworkInterface ni1 = NetworkInterface.getByInetAddress(add); if (ni1 !=...

ASP.NET: produce an error message when a non-numeric value is entered in a textbox?

If a user enters a non-numeric value into a TextBox and presses a Button, I want to show an error message on a Label. How can I achieve this? ...

What does it mean when var_dump reports the wrong string length?

I'm trying to figure out why a variable isn't triggering a conditional that it should. var_dump reports something like this: string(20) "0" Why is it reporting a length of 20 when the length is clearly 1? ...

How can I get Ruby to treat the index of a string as a character (rather than the ASCII code)?

I am checking to see if the last character in a directory path is a '/'. How do you get ruby to treat the specific index of a string as a character rather than the associated ASCII code? For example the following always returns false: dir[dir.length - 1] == '/' This is because dir[dir.length - 1] returns the ASCII code 47 (rather ...

how can I convert a dictionary to a string of keyword arguments?

we can convert the dictionary to kw using **kw but if I want kw as str(kw) not str(dict), as I want a string with keyword arguments for code_generator, if I pass obj.method(name='name', test='test', relation = [('id','=',1)]) I want a function to return the string like "name='name', test='test', relation = [('id','=',1)]" ...