[Solved] How Much Faster is StringBuilder respect of concat operator + in C# .Net [duplicate]

The Microsoft Developer Network has a great comparison: Although StringBuilder and String both represent sequences of characters, they are implemented differently. String is an immutable type. That is, each operation that appears to modify a String object actually creates a new string. For example, the call to the String.Concat method in the following C# example … Read more

[Solved] C# Accessing field syntax

You can use reflection to access a field by its name : FieldInfo ageField = typeof(Person).GetField(“age”); int age = (int) field.GetValue(person); solved C# Accessing field syntax

[Solved] Base64 decoding – incorrect string length

Are you using str[n]cpy? You can’t! Base64 encoded data can contain null characters, which C string processing functions interpret as end-of-string. Use memcpy instead of str[n]cpy, memcmp instead of strcmp, etc. These functions require you to know your data size, but I believe that you do know it. Also if you’re not very confident about … Read more

[Solved] How to read the entire content of a file character by character?

I would do this like this: std::ifstream infile(“myfile.txt”); char ch; while(infile.get(ch)) { … process ch … } This avoids the problems that appear on the last character, or having to read a character before the first iteration of the loop. solved How to read the entire content of a file character by character?

[Solved] Got stuck with Caesar.c

A function to caesar an alphabetic char should be like (decomposed in elementary steps): int caesar_lower(int c,int key) { int v = c-‘a’; // translate ‘a’–‘z’ to 0–25 v = v+key; // translate 0–25 to key–key+25 v = v%26; // translate key–key+25 to key–25,0–key-1 v = v+’a’; // translate back 0–25 to ‘a’–‘z’ return v; … Read more

[Solved] Convert a `while` loop to a `for` loop

I think it should be something like this : for(;a<b–;){ for(d += a++ ; a != c ; ) { d += a++; } c+= a&b } The above logic works ! I ran both programs as below and they output the same result : Program1:[derived from your program 1] #include<stdio.h> int main(){ int a=10,b=10,c=10,d=10; … Read more

[Solved] If Statement not Working right [closed]

Assuming the statement you’re testing is actually ‘How is the weather’ then your if statement is working as expected. Your checks are seeing if the statement contains ‘weather’ and ‘what’ OR contains the word ‘how’ (note the lower case). As your phrase doesn’t contain the word ‘what’ the first check (for the words ‘weather’ AND … Read more