|
Richard Deeming wrote:
ReadOnlySpan<char> input = "ABCD";
ReadOnlySpan<byte> bytes = System.Runtime.InteropServices.MemoryMarshal.AsBytes(input);
int value = System.Runtime.InteropServices.MemoryMarshal.Read<int>(bytes); Will that compile to a single instruction, as you might see when using C/C++ casting?
If you want to treat 4 chars at a time by treating them as ints, this doesn't look like something that would save CPU cycles. I admit that I haven't tried to compile the code and studied the instructions generated.
Endianness isn't your only concern. Don't forget that UTF16, the internal character format of C#, also can contain surrogates and other funny elements.jschell wrote: So a value like "ABCD" can be cast directly to a 32 bit unsigned integer. obviously expecting a result of 1 094 861 636, hex 41424344 on big-endian machines, 1 145 258 561, hex 44434241 on little-endian machines. With UTF16 representation, the value 4325441, hex 00420041, encodes only two characters, "AB", not four as the C++ programmer expected. (C# never used 8 bit char representation, so the C# should not expect that four chars are packed into a 32 bit int.)
Religious freedom is the freedom to say that two plus two make five.
|
|
|
|
|
For literals, the other alternative would be to use a UTF8 string literal:
ReadOnlySpan<byte> bytes = "ABCD"u8;
int value = System.Runtime.InteropServices.MemoryMarshal.Read<int>(bytes);
It's not going to compile to a single instruction, but it should be fairly well optimized.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
ReadOnlySpan<byte> bytes = "ABCD"u8;
You see, I had no idea you could do that. u8 - when did that arrive?! Can't keep up with it all.
Regards,
Rob Philpott.
|
|
|
|
|
|
I think that is one of the (few) useful extensions to C# in recent years.
Religious freedom is the freedom to say that two plus two make five.
|
|
|
|
|
That solves the issue if you restrict yourself to 7-bit ASCII.
Even for West European languages (such as Norwegian), a character may fill more than one octet. So if you step through a string 4 characters at a time, converting them to 32 bits, you will miss 8 bits here and there. Can lead to nasty, hard-to-debug errors when it happens with a customer on the other side of the earth, using a language with lots of multi-octet UTF8 characters.
Religious freedom is the freedom to say that two plus two make five.
|
|
|
|
|
П.... не копил Editor3D_Render_Control на 2022 MSVStuio
|
|
|
|
|
write your question in English and NOT with kyrillic letters ...
|
|
|
|
|
I'm sorry, your question makes no sense. First of all, this is an English speaking site so please post questions in English. Second, when I translated your question, it said:
P.... didn’t save Editor3D_Render_Control for 2022 MS VStuio What does that even mean?
|
|
|
|
|
What did you use to translate? Google produces "screw up" instead of "save" for me.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
If you mean this control: Editor3D: A Windows.Forms Render Control with interactive 3D Editor in C#[^] then don't post this under a "generic" forum like C# - if you got the code from an article, then there is a "Add a Comment or Question" button at the bottom of that article, which causes an email to be sent to the author. They are then alerted that you wish to speak to them.
Posting this here relies on them "dropping by" and realising it is for them.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
In VS 2022 I can not find any templates for WinUI. I installed Windows SDK and WinUI controls but I can not find any templates. Any idea why ?
Thanks
|
|
|
|
|
|
|
Did you install the correct workloads by following the link in point 1?
|
|
|
|
|
|
|
|
|
Thanks. I found that I must install "window sdk templates"
|
|
|
|
|
I found that I must install windows app desktop templates !!
|
|
|
|
|
I found that I must install windows app desktop templates !!
|
|
|
|
|
Hello friend! I am developing a Windows application (WinForms) to manage universities with c#, it is an application that is very complex because it is a Multi-user application, I want that for this application I can use a single database centralized by all users of this application, which will be managed by myself and my development team. Is this possible? What would be the best and least expensive solution, taking into account my capacity? Also in terms of cost, between a SQL SERVER EXPRESS database and a MySQL database, which one might be better for me? And which one is well suited to C#, using Crystal Report and Visual Studio as well? Your answers will help me a lot to make a decision and also develop an efficient solution.
I'm thinking about whether it's possible to host only my SQL SERVER EXPRESS, or MySQL database to which my Windows software or application designed in C# can connect remotely so that the various users of my device can access the remote database
Thank you for your help
modified 25-Apr-24 10:40am.
|
|
|
|
|
theo tuombe wrote: taking into account my capacity?
You didn't specify anything about capacity.
theo tuombe wrote: to manage universities with c#,
Manage what? Class schedules? Budgets? Lawn care?
theo tuombe wrote: What would be the best and least expensive solution
No idea. Even if you had all of the missing detail anyone that claimed that they could decide both of those would be, let us say, less well informed about the subject than one might hope.
theo tuombe wrote: And which one is well suited to C#
This is one of those factors where "best" has many meanings. If you plan on being a windows shop then staying with windows which means SQL Server is probably going to be the least amount of trouble.
Now if you or others that work on this have experience both in C# and other data persistence stores then there are other options. But then I suspect you would have already been able to evaluate that without asking here.
If you are VERY careful with how you write your code and your design then it is possible that you can switch databases relatively easily if you find you want a different solution. But unfortunately that again is probably dependent on experience.
|
|
|
|
|
Thank you very much Dear jschell for your answer to my question posed in the forum.
"taking into account my capacity?" I mean taking into account the cost,
"managing universities with c#" is really the input errors. To be clear with my question, I wanted to ask that I develop a WinForms application to manage universities with the programming language c#, the application I develop is an application that must manage the entire university including student management, budget management, course management etc.. It's an application that I want, after development, to be able to deploy to different universities, which are then the end users of my application. So I'm asking what solution I can use so that my application installed on different users' computers can use a single database! without error connection to database??
Thank you
modified 25-Apr-24 10:39am.
|
|
|
|