|
I think it's clever, but I can't say that I'm thrilled that this is possible. If I were using a library and got a "possible null reference exception" from a value type, I'd likely waste a fair amount of time trying to figure out what was going wrong.
I'm generally not a fan of blurring the lines between values and references.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
Thanks for your thoughts, Nathan !
I'm not advocating this as the "best way:" I can see a valid argument foe using an out parameter, and returning a bool ... building on the 'TryParse syntax we are used to. I think I'll add the code for that technique to the post, and perhaps, get some more reactions.
By the way: in practice, I'm fanatic about controlling numeric entry in TextBoxes by using Key Event handlers to screen out unacceptable key entries, so this experiment is just a challenge I took on to get familiar with the 'TypeConverter facility.
The use of the currently shown code looks like this:
var v0 = tBxNumericUC1.Text.TryParse1<int>();
if (v0 != null)
{
} The usage of the code that's more like 'TryParse would look like:
if (tBxNumericUC1.Text.TryParse<int>(out int iresult)
{
}
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
modified 11-Jun-18 14:15pm.
|
|
|
|
|
I have a couple of custom MVC implementations that act similarly. I'm working on one of those projects now, and I must confess that I forgot how hard it can be to troubleshoot.
Also: pretty much every other line is a null check. I sort of hate that
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
|
Google translate: "I posted this in the appropriate place, but I didn't get a quick enough reply so I thought I'd drop hints everywhere else".
They are getting clever these days, Google...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
|
Your original post was in the correct forum.
Spamming other forums with "please look at my post" messages just because you didn't get an answer quickly enough is, at best, annoying.
Remember, the people answering questions here are volunteers. Nobody is under any obligation to answer your question at all, let alone within a particular time-frame.
Also, members are spread out across the globe, and may not have had a chance to see your original post yet.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
An excellent translation of my translation!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Your post came across as a snide put down rather than a constructive comment.
|
|
|
|
|
Leif Simon Goodwin wrote: Your post came across as a snide put down rather than a constructive comment. Which tends to happen if you rub a volunteer the wrong way. You're not guaranteed a constructive comment on public forums.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
I resent the use of the term spamming and the confrontational tone of your posting.
For your information I had an account with another name (company email, no longer accessible), posted in the WPF forum, got no answer after many days, posted a link in this forum, and got an answer almost immediately. Hence why I am/was not sure which was the best forum for the question.
|
|
|
|
|
|
Thank you for the constructive suggestion.
|
|
|
|
|
I have C# COM dll used in one of the module (lets call as A) and it already into the market.
For my other new module , i need same functionality as C# COM dll, So i used the same code and generated dll(the Common C# DLL is same for two modules and need to located in same place after installation)
Since C# COM dll name and location is same for both modules, i cant work on both the modules at a time
either i need to play with register /unregister and work with one module.
How can i make this C# COM dll with same name and same location to work for two projects/modules?
Help is greatly appreciated.
|
|
|
|
|
Member 11732139 wrote: i need same functionality as C# COM dll, So why are you creating a different dll?
|
|
|
|
|
the two modules are different and install packages of modules are different
when two modules insatlled in machine then common dll contradicts!!
|
|
|
|
|
Sorry, but I do not understand what you mean. If you have a common dll then you only need it installed once.
|
|
|
|
|
This is possibly a misunderstanding because the word you are using mean something else in this context: perhaps you should try explaining again in more detail exactly what is giving you a problem?
Examples help as well!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
cant send file bigger that 1 megabit ( Server_client )
private byte[] GetFileInfo(string fname, string fext, long fsize)
{
byte[] data = new byte[1024];
byte[] type = Encoding.UTF8.GetBytes("fff");
byte[] ext = Encoding.UTF8.GetBytes(fext);
byte[] extE = Encoding.UTF8.GetBytes(":");
byte[] sizeS = Encoding.UTF8.GetBytes(fsize.ToString());
byte[] sizeE = Encoding.UTF8.GetBytes("s");
byte[] name = Encoding.UTF8.GetBytes(fname);
byte[] nameE = Encoding.UTF8.GetBytes("?");
Array.Copy(type, data, type.Length);
Array.Copy(ext, 0, data, type.Length, ext.Length);
Array.Copy(extE, 0, data, ext.Length + type.Length, extE.Length);
Array.Copy(sizeS, 0, data, ext.Length + type.Length + extE.Length, sizeS.Length);
Array.Copy(sizeE, 0, data, ext.Length + type.Length + extE.Length + sizeS.Length, sizeE.Length);
Array.Copy(name, 0, data, ext.Length + type.Length + extE.Length + sizeS.Length + sizeE.Length, name.Length);
Array.Copy(nameE, 0, data, ext.Length + type.Length + extE.Length + sizeS.Length + sizeE.Length + name.Length, nameE.Length);
byte[] newdata = new byte[ext.Length + extE.Length + sizeS.Length + sizeE.Length + name.Length + nameE.Length + type.Length];
Array.Copy(data, newdata, newdata.Length);
return newdata;
}
private byte[] GetBinaryFile(string filename)
{
byte[] bytes;
using (FileStream file = new FileStream(filename, FileMode.Open, FileAccess.Read))
{
bytes = new byte[file.Length];
file.Read(bytes, 0, (int)file.Length);
}
return bytes;
}
}
}
modified 7-Jun-18 1:26am.
|
|
|
|
|
Please delete your duplicate of this question. Also, edit this and remove all the code not relating to the problem, and add some details about exactly what happens.
|
|
|
|
|
Is this for a DOS attack?
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Is that MS-DOS or PC-DOS?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
|
|
You programmed all that, and can't figure out what determines the length of the buffer?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|