|
Thank you Heath, exactly the kind of info I am looking for. Real world use and experience. They all have flashy looking demos.
regards,
Paul Watson
Bluegrass
South Africa
Chris Maunder wrote:
"I'd rather cover myself in honey and lie on an ant's nest than commit myself to it publicly."
Jon Sagara replied:
"I think we've all been in that situation before."
Crikey! ain't life grand?
|
|
|
|
|
I'm going to get my devexpress controls re-installed and check those out and compare. I've been thinking about dropping the UltraWinTree for something better, but I really need to compare. If I remember, I'll try to post back what I find (such as if Developer Express belives in good OO design with virtual methods and properties (where reasonable).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
Thanks Michael, it comes with the Infragistics Ultra Win Tree which is great.
regards,
Paul Watson
Bluegrass
South Africa
Chris Maunder wrote:
"I'd rather cover myself in honey and lie on an ant's nest than commit myself to it publicly."
Jon Sagara replied:
"I think we've all been in that situation before."
Crikey! ain't life grand?
|
|
|
|
|
|
Sub : How to use Amazon Web Services..
Hi all...
Please let me know How to start with amazon web services..
I'm not finding any XML or REST Query format to send request to amazon..
I've purchased Seller account but How to use that to upload Items..I don't know...
Please help me getting start..
I hope some one definatly know about this
e-mail if attachment at sumit_kapoor1980@hotmail.com
Thanks...
..---Sumit Kapoor---
|
|
|
|
|
Here are three articles on Code Project which tell you how:
regards,
Paul Watson
Bluegrass
South Africa
Chris Maunder wrote:
"I'd rather cover myself in honey and lie on an ant's nest than commit myself to it publicly."
Jon Sagara replied:
"I think we've all been in that situation before."
Crikey! ain't life grand?
|
|
|
|
|
Stop Cross posting and take a look: The answer is already on Code Project, if you would care to look.
My suggestion is to use the little search box near the top of this page and type "Amazon web services", ensure the drop down says "Articles" and then press "Go". You'll be amazed at what you can find.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
|
|
|
|
|
The effect is the same, but which one is faster?
if(s == String.Empty)
or
if(s.Length == 0)
?
|
|
|
|
|
From Performance Strategies for Enterprise Web Site Development here on CP:
There is one more item I’d like to address when talking about strings, and that is checking for an empty string. There are two basic ways to check if a string is empty or not. You can compare the string to the String.Empty static property, which is just a constant for “”:
if (firstName == String.Empty)
Or you can check the length of the string, like this:
if (firstName.Length > 0)
I setup a test in the .NET Test Harness and found that the String.Empty comparison check was 370% slower than the length check. This may seem fairly trivial, but every little bit helps, right?
regards,
Paul Watson
Bluegrass
South Africa
Chris Maunder wrote:
"I'd rather cover myself in honey and lie on an ant's nest than commit myself to it publicly."
Jon Sagara replied:
"I think we've all been in that situation before."
Crikey! ain't life grand?
|
|
|
|
|
Paul is right. If you run your code through the FxCop assembly analyzer, it'll chide you for using if(myString == string.Empty), telling you to use if(myString.Length == 0) instead.
#include "witty_sig.h"
|
|
|
|
|
So why did they bother inventing String.Empty I wonder ?
Try not! Do or do not, there is no try. - Master Yoda
|
|
|
|
|
Because it's faster than loading your own literal "" when needed. There's still uses for it. Perhaps you want to initialize a string member as an empty string instead of null. Just because something may not be useful in one case doesn't mean it's not useful in another.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hello! what can I convert a char* to string?
The cast isn't permitted!
Thanks
|
|
|
|
|
public void ConvertStringChar(string stringVal) {
char charVal = 'a';
// A string must be one character long to convert to char.
try {
charVal = System.Convert.ToChar(stringVal);
System.Console.WriteLine("{0} as a char is {1}",
stringVal, charVal);
}
catch (System.FormatException) {
System.Console.WriteLine(
"The string is longer than one character.");
}
catch (System.ArgumentNullException) {
System.Console.WriteLine("The string is null.");
}
// A char to string conversion will always succeed.
stringVal = System.Convert.ToString(charVal);
System.Console.WriteLine("The character as a string is {0}",
stringVal);
}
|
|
|
|
|
char* someCharPtr;
string myString = new string(someCharPtr);
#include "witty_sig.h"
|
|
|
|
|
ok, I converted a char* into a string as:
string descr= new String(obj[1].descr);
but the problem isn't solved:
//obj[] is:
public struct node {
public int IdObj;
public char* descr;
}
node* obj=getObj();
//getObj is the function included into a DLL
//the string "descr" contain only simbols!!!
thanks for your help!
|
|
|
|
|
Why are you using char* in a .NET struct anyway? Stay away from unmanaged types when possible. A char* or char[] is just a string in any language. Even when P/Invoking native functions, you still typically use a string in place of any character array (char* , wchar_t* , TCHAR* , etc.). It will marshal correctly so long as you marshal using the correct character set (see the CharSet property of the MarshalAsAttribute or StructLayoutAttribute if you're doing this to P/Invoke some native function).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
If i try to replace the char* to string, the compiler make me the following error:
"Impossible accept address/dimension of variable of managed object."
So the only not managed object are char,int,ecc but not string! (independently of "unsafe" environment)
ps: the language used to build the function into a DLL is the C++, so the "string" is a char[].
|
|
|
|
|
A string is also a char* . The difference is how the character array (string) is allocated.
There are properties you can set using the MarshalAsAttribute that I mentioned earlier) that specify the maximum size (in characters, not bytes) or a parameter index that does the same within a struct (if one exists). Read the documentation for the MarshalAsAttribute in the .NET Framework SDK for more information. Trust me, my forté is unmanaged interop. I've never had to use a single unsafe context to P/Invoke anything from basic to complex structs and function calls. They're really only necessary when you need to boost performance of a block of code; for example, iterating through the bits of a bitmap - using an unsafe context is much faster.
You should also see the Marshal class, which includes methods that further prevent you from having to use an unsafe context (because it does it for you, like alloc'ing memory).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Ok, I'll read the MarshalAsAttribute documentation!
Thanks very much for help!
|
|
|
|
|
Do I need to know about the encoding of a file before opening it or is it determined automatically by the framework? If .NET framework cannot automatically determine, then is there any way I can find this out myself? I'm not clear about this character encoding thing, so if you can please explain in detail, that would be of great help.
Thx
Gurmeet BTW, can Google help me search my lost pajamas?
My Articles: HTML Reader C++ Class Library, Numeric Edit Control
|
|
|
|
|
StreamReader has several constructors, some of which take an Encoding and/or a boolean value to indicate whether the encoding should be detected or not.
A bit of poking around in Reflector reveals that if you don't provide an encoding, it uses UTF8, and if you don't say otherwise, it tries to detect the encoding rather than use the default UTF8.
When trying to detect an encoding, it uses the Byte Order Mark character. The Unicode standard indicates that this character, U+FEFF, should appear at the beginning of the text in whatever encoding is used. In UTF-16 little-endian, this becomes the byte sequence 0xFF 0xFE; in UTF-8, it's (IIRC) 0xEF 0xBB 0xBF. If there's no Byte Order Mark, it simply uses the encoding specified in the constructor, unless you didn't use one of those variants, in which case it uses UTF-8. .NET can also detect UTF-16BE, or big-endian, where the bytes of UTF-16 are the other way round.
If you use File.OpenText or FileInfo.OpenText , you don't get to specify an encoding.
Unfortunately very few of us have files encoded as UTF-8. They're far more likely to be encoded using our default code page. For most Western European and North American users, this is going to be Windows 1252 (Windows Western). You can get hold of an encoding for the user's configured ANSI code page using Encoding.Default .
Western users, particularly UK, US and Canada, may not notice at first that the encoding is different, because the first 256 code points of Unicode are the same as ISO Latin 1 (a little, though not a lot, different from 1252). Due to the way it's encoded, the first 128 code points of UTF-8 are also the same as Latin 1 and ASCII (ISO-646-US). Any UTF-8 code byte greater than 127 indicates that one or more following bytes needs to be interpreted along with this one to get the full character.
There's no reliable way to detect which encoding is used by a random sample of text in a byte-oriented character stream (which isn't UTF-8). The concept of Byte Order Marks is relatively new. You either have to know or ask the user.
More information links:
Microsoft Global Development Portal[^]
Code Page reference tables[^]
The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)
[^]
http://www.unicode.org/[^]
Character Sets[^] (from my blog).
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Great information, thanks Mike.
regards,
Paul Watson
Bluegrass
South Africa
Chris Maunder wrote:
"I'd rather cover myself in honey and lie on an ant's nest than commit myself to it publicly."
Jon Sagara replied:
"I think we've all been in that situation before."
Crikey! ain't life grand?
|
|
|
|
|
Great information!
I just wanted to add that BOMs (byte order marks) aren't always present in a text file as well. There no requirement for BOMs.
While there's no reliable way to detect encoding - like you said - web browers and other applications (like Word) do try to detect the encoding. If you - the original poster - needs to do something like that, a simple (but probably not the most efficient way) is to take a random sampling of strings within the text file and use StringInfo.GetTextElementEnumerator and enumerate the text elements. With either all of those or a random sample, call TextElementEnumerator.GetTextElement (returns a String ) and check the Length . If it's greater than one, you at least know you're dealing with a multi-byte character set (MBCS), like UTF-8. If all of them were 2 bytes, then it's likely it's a double-byte character set (DBCS), like UTF-16 (there's also 4-byte characters, known as UTF-32!). If they're all 1 byte, then you've probably got an ASCII (or other single-byte encoding) file. From there you can make certain assumptions. You see browsers doing this when they start displaying question marks for chracters in odd places (this also happens when the specified encoding is wrong).
Microsoft MVP, Visual C#
My Articles
|
|
|
|