Do upper case letters take up more memory? [closed] - c#

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I'm trying to create a file system that will handle lots of searching through the directories. Would it make a difference if I used upper or lower case letters in terms of memory usage on the folder names?

Case does not affect the size of a character. Some characters take up different sizes in certain character encodings, but generally letters from the same language all have the same size.

No. Each character takes up the same amount of memory.
You can get into some technicalities with character sets and encoding, but unless you've got a really obscure one, uppercase and lowercase use the same number of bits.

No. Especially assuming that you're only using ascii characters.

No. Both are of type char which is defined in C# as 16-bit long numeric value. More reference:
https://msdn.microsoft.com/en-us/library/x9h8tsay.aspx

A data type char must have at least big enough to contain an encoding of at least the 95 different characters which make up the basic execution character set.
This equals a minimum of 8 bits, or one byte. Meaning a or A in a variable char will at least require 1 byte. So no, it's the same.

Related

Equivalent of assigning char on c++ to c# [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
Does anyone know how to implement the following c++ code in c#
c++
char t = '\0';
t += (char)3;
the output of t would be equal to '\x3'
if I implement the same code in c#
char t = '\0';
t += (char)3;
the output would be different t = '\u0003'
How could I get the same result in c#??
thanks
In both languages the escape sequence \xnn represents a character with the specified byte value nn in hexadecimal.
In both languages the escape sequence \unnnn represents the unicode code point nnnn.
It so happens that the byte value 3 corresponds to the unicode code point U+0003 in the encoding used by C#. This is why the output in C# is \u0003.
The code in both languages does roughly the same thing and both ts will store a value of 3 after both code run. The difference is in the format of the output. I don't know how you get \u0003 as output in C#. Console.WriteLine will print the character out, not its unicode code point.
You can't really get the same output in C# because C# chars are represented differently than those in C++. C++ chars are usually 1 byte, while C# chars are as big as a ushort.

Generating folders using textboxes [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
Hello experts, I have to generate series of folders from a TextBox into specified location.I am having two textboxes to specify the limit of folders(say 30 folders).The problem am facing is that the folder names that i will be providing are alpha-numeric(say 121cs3h101) .
How to set limit when i provide an alpha-numeric values?
(For example: i provide textbox1=12cs3h101 and textbox2=12cs3h131 , i need the series limit to be generated). I am working with visual studio 2013 in c# windows form application. Thanks in advance.
ok I will try to give you a lead.
To parse a string or find specific characters one can use RegEx.Match or a simler method called String.Split. In both cases you have to be aware how your string is structured and how it can vary. The limits of variation are very important.
If as you say the beginning is always"12cs3h" you can either split the string at the character 'h'.
string[] sa = s.Split('h');
Or you can even use the index of 'h' (since the length seems to be fixed) and take the rest of the string to get the numbers.
int index = s.IndexOf('h');
The rest is up to you, ... convert, enumerate and so on.
EDIT: There is a nice method that does the enumeration job for you: Enumerable.Range Good luck

Adding two different digit Numbers in c# ( without using BigInteger) [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
I have a Task to do C#. I need to add two numbers.
The first number contains around 100 digits like "12822429847264872649624264924626466826446692............"
and second number also with 100 digits or more or less
by using this numbers i need task like add/sub/multiply/div
I done this using BigInteger in C#
But do I need to do this using arrays or strings?
Since they are both 100 digits just start with the last digit and in a for loop just add each one, but if the value is > 10 then remember to add one to the next digit.
This is how children learn to add, you just need to follow the same steps, but the answer should be in an array of 101 characters.
UPDATE:
Since you have shown some code now, it helps.
First, don't duplicate the code based on if str1 or str2 is larger, but make a function with that logic and pass in the larger one as the first parameter.
Determine the largest size and make certain the smaller value is also the same size, to make math easier.
The smaller one should have leading zeroes (padding), again to help keep the code simple.
You can also start by looking at the source code for structures such as BigInteger. They would provide you more insight into aspects such as computational efficiency and storage, particularly about multiplication and division. You can take a look at here or here.

How to insert | and || operators in C#? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
In VB.NET, I can quickly type And/AndAlso on the keyboard. In C#, I'm currently opening Character Map and copying the 'OR' vertical line character manually. Am I missing something that allows quick insertion of the line symbol?
It is also called the pipe key, on many keyboards (UK/US) it is a single broken vertical line (one some keyboards it is a single unbroken vertical line, but I mostly see it as a broken one).
Image from here.
Depends on the keyboard layout, but the | / pipe should be somewhere on the left of the enter key (US layout), or on the left of Z or 1 (first normal, the other with AltGr, UK layout).
Wherever you have the PIPE key, you could type, on the numeric keypad and keeping the ALT key pressed, the number 124
I don't know where you are from, but assume that you have a non-english keyboard. Unfortunately the C language (where this and other syntactic elements) originates from was developed with the english standard keyboard in mind.
I know some people here in Sweden are switching to english keyboard layout when coding - to get rid of the awkward placement of key C/C# characters like | { [ ] } \. (They are all combinations that require the AltGr key. Something had to be done to make place for the Swedish characters ÅÄÖ that all have their own keys.)
I have the "pipe" symbol as altGr + 1

Validate a UK phone number [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
How do I validate a UK phone number in C# using a regex?
The regex in the accepted answer does not match all valid UK numbers, as it is too restricive (additional number ranges have been opened up in the meanwhile such as 0203, which it sees as invalid).
UK phone numbers follow fairly simple rules:
They can be either 10 or 11 digits long (with the exception of some special numbers, but you're unlikely to need to validate those)
They consist of an area code followed by a local number. The area code varies in length between three and five digits, and the local portion of the number takes up the remaining length of the 10 or 11 digits. For all practical purposes, no-one ever quotes just the local portion of their number, so you can ignore the distinction now, except for how it affects formatting.
They start with zero.
The second digit can be anything. Currently no valid numbers start with 04 or 06, but there's nothing stopping these ranges coming into use in the future. (03 has recently been brought into use)
They can be formatted with a set of brackets and with spaces (one or more, in varying positions), but those are all entirely optional.
Therefore, a basic working expression for UK phone numbers could look like this:
/^\(?0( *\d\)?){9,10}$/
This will check for 10 or 11 digit numbers, starting with a zero, with formatting spaces between any of the digits, and optionally a set of brackets for the area code.
(and yes, this would allow mis-matched brackets, as I'm not checking that there's only one closing bracket. Enforcing this would make the expression a lot more complex, and I don't have time for this right now, but feel free to add this if you wish)
By the way, in case you want to do additional filtering, you might want to also note the following rules:
Numbers starting 08, 09 and 070 are special price numbers, and would not generally be given as private numbers, so can be excluded if validating a private number.
07 numbers are mobile (except 070; see above) so can be excluded if you're specifically validating for a landline.

Categories

Resources