string

C# How can I get the value of a string property via Reflection?

public class Foo { public string Bar {get; set;} } How do I get the value of Bar, a string property, via reflection? The following code will throw an exception if the PropertyInfo type is a System.String Foo f = new Foo(); f.Bar = "Jon Skeet is god."; foreach(var property in f.GetType().GetProperties()) { object o...

Converting a String to Dictionary?

How can i convert the following: s = "{'muffin' : 'lolz', 'foo' : 'kitty'}" Into a dictionary object? I'd prefer not to use eval() what should i do? The main reason for this, is one of my coworkers classes he wrote, converts all input into strings. I'm not in the mood to go and modify his classes, to deal with this issue. ...

Strongly typed calls into web.config without duplicating the property names?

I searched here for the answer. I'm sorry if this has been asked before (as I suspect it has). Summary: How can I have strongly typed calls into my web.config without duplicating the property names? Details: In my code, I try to minimize string usage, and I don't like defining something twice. Complementing both of these wonts is m...

How to get count of next combinations for given set?

I've edited original text to save potential readers some time and health. Maybe someone will actually use this. I know it's basic stuff. Probably like very, very basic. How to get all possible combinations of given set. E.g. string set = "abc"; I expect to get: a b c aa ab ac aaa aab aac aba abb abc aca acb acc baa bab ... and the lis...

Why doesn't Ruby automatically execute to_s?

I have an author class: class Author < ActiveRecord::Base def to_s name end end Defining to_s allows me to do puts Author.first, but not puts Author.first.rjust(10): NoMethodError: undefined method `rjust' for #<Author:0x21eb5d4> Wouldn't it be better if Ruby automatically tried to_s before the string method in cases like t...

What characters can I use to quote this ruby string ?

I'm embedding JRuby in Java, because I need to call some Ruby methods with Java strings as arguments. The thing is, I'm calling the methods like this: String text = ""; // this can span over multiple lines, and will contain ruby code Ruby ruby = Ruby.newInstance(); RubyRuntimeAdapter adapter = JavaEmbedUtils.newRuntimeAdapter(); String...

Java string comparison?

String parts is String[6]: [231, CA-California, Sacramento-155328, aleee, Customer Service Clerk, Alegra Keith.doc.txt] But when I compare parts[0] with "231": "231" == parts[0] the above result is false, I'm confused, so could anybody tell me why? ...

ForEach String concat

Hi, A little newbie question. I have a foreach loop where I am trying to access the property of a row object and assign to a string. foreach(row in Dataset) { string finalName= row.name; } On each iteration I need to concat each row's name property to the finalName \Thanks alot, ...

string [,] and repeater

Hello How do I write out my array with a repeater? string[,] month = { {"Januari", "Februari", "Mars", "Apri", "Maj", "Juni", "Juli", "Agusti", "September", "November", "Oktober", "December"}, {"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"} }; Now I can use Container.Data...

How to convert a simple string to Byte Array in VBA?

I need to convert a simple string in a Byte array using excel VBA. Then this byte array is used as the request's body. How can I do that? Thanks. ...

C# - Show the differences when comparing strings

In my asp.net project, I have two strings (actually, they are stored in a Session object, then i do a .ToString() ) This project is part of my free Japanese language exercises on my website (Italian only for now, so i won't link/spam) For now i do an if (original == inputted.ToLower()) , but I would like to compare the strings and high...

STL string comparison functor

Hi all! I have the following functor: class ComparatorClass { public: bool operator () (SimulatedDiskFile * file_1, SimulatedDiskFile * file_2) { string file_1_name = file_1->getFileName(); string file_2_name = file_2->getFileName(); cout << file_1_name << " and " << file_2_name << ": "; if (file_1_name <...

Oracle 'printf' equivalent

Is there an equivalent or alternative to the following? SELECT mix_type || ' (' || mix_num || ')' as description FROM acid_batch WHERE mix_num < 10 Does Oracle have something like printf style formatting? SELECT printf("%s (%s)", mix_type, mix_num) as description, FROM acid_batch WHERE mix_num < 10 ...

byte[] to string in c#

I have a .NET byte[] that is loaded from a file that I happen to known contains UTF-8. In some debugging code, I need to convert it to a string. Is there a one liner that will do this? Under the covers it should be just an allocation and a memcopy so even if it is not implemented, it should be possible. ...

How to find all naive ("+" based) string concatenations in large Java codebase?

We have a huge code base and we suspect that there are quite a few "+" based string concats in the code that might benefit from the use of StringBuilder/StringBuffer. Is there an effective way or existing tools to search for these, especially in Eclipse? A search by "+" isn't a good idea since there's a lot of math in the code, so this ...

How do I get the length (i.e. number of characters) of an ASCII string in VB.NET?

I'm using this code to return some string from a tcpclient but when the string comes back it has a leading " character in it. I'm trying to remove it but the Len() function is reading the number of bytes instead of the string itself. How can I alter this to give me the length of the string as I would normally use it and not of the arra...

A Python buffer that you can truncate from the left?

Right now, I am buffering bytes using strings, StringIO, or cStringIO. But, I often need to remove bytes from the left side of the buffer. A naive approach would rebuild the entire buffer. Is there an optimal way to do this, if left-truncating is a very common operation? Python's garbage collector should actually GC the truncated bytes. ...

Stack overflow when replacing ' with '' in VB 6.0

I'm looking into some legacy VB 6.0 code (an Access XP application) to solve a problem with a SQL statement by the Access app. I need to use replace single quotes with 2 single quotes for cases where a customer name has an apostrophe in the name (e.g. "Doctor's Surgery": Replace(customerName, "'", "''") Which will escape the single qu...

C# Enum values

I have a enum containing the following (for example): UnitedKingdom, UnitedStates, France, Portugal In my code I use Country.UnitedKingdom but I want to have the value be UK if I assign it to a string for example. Is this possible? ...

C#: Cleanest way to divide a string array into N instances N items long

I know how to do this in an ugly way, but am wondering if there is a more elegant and succinct method. I have a string array of e-mail addresses. Assume the string array is of arbitrary length -- it could have a few items or it could have a great many items. I want to build another string consisting of say, 50 email addresses from the ...