|
You can have a Nullable structure.
struct Dummy{
public string dummyvalue;
}
Dummy? dummyStrct = null;
|
|
|
|
|
|
You have been very polite
|
|
|
|
|
Maybe if you make an implicit cast operator from object to Null<T> ? The object could be null, obviously, so if you tried to assign null to it it should think the null is an object and call your implicit cast operator.
Last modified: 29mins after originally posted --
|
|
|
|
|
|
They cheat by making the compiler support it, which we can't do
Anyhow did an implicit cast from an object work?
|
|
|
|
|
|
Ok well the idea was that make a
public static implicit operator Null<T>(object value)
{
if (value is T)
return new Null<T>(value);
else if (value == null)
return new Null<T>(null, true);
else
throw new Exception("this is bad, but find a better exception");
}
And then Null<t> can be a struct, I think. Try first..
|
|
|
|
|
Ahhh sorry didnt see that one, no this is not allowed, as it tries to convert from a base class which is not allowed.
Following error returned:
Null<T>.implicit operator Null<T>(object)': user-defined conversions to or from a base class are not allowed
With great code, comes great complexity, so keep it simple stupid...
|
|
|
|
|
Ok, didn't think of that, than use something else that is not a base type - say string, or some little holder class that does nothing except have the ability to be null.
Does it even say that when Null<T> is a struct?
|
|
|
|
|
|
Ok good, you're welcome
|
|
|
|
|
|
Can't you use
private Null<int?> index = null;
or
private Null<int>? index = null;
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
|
Hi
I have been using Total Copy for like for ever, but I always wanted to write my own App for copying files with the same functionality.
How can I pause and resume the copy of a file in C# (WinForms) as Total Copy does?
I've tried Googling, but I'm not finding what I'm looking for.
Thanks in advance.
|
|
|
|
|
Use FileStream to copy the source file into the target file. When you want to pause the opration you just need to close the stream. When you want to resume, you can use seek method find last written byte and restart writing.
Another way could be to have copy operation on a separate thread which can be stopped and resumed when required. I have not tried this hence not sure.
Hope this helps.
|
|
|
|
|
Thanks for the reply. Maybe binary Reader would do the job... will check it out.
|
|
|
|
|
Hi all
on a video stream display control i have i've got an overlay bitmap on which I can add markers. the bitmap is defined to be the size of the video stream (say 640X480 for a webcam), but the user can resize the display, so the videoimage + bitmap are also resized befor display . i've got markers drawn by the Graphics.DrawLine(...) with a 1 pixel width Pen. the user can also move the markers about. if the resize is by a whole number (say, resize the 640x480 to 1280x960 and so on) there are no problems, bit if the ratio is fractional (say 640x480 to 1024x768, which is 1.6) i have the following artifect: whenever the coordinate times the ratio gives a float with the fractional part larger than 0.5, the line thins out by a pixel. so if i'm running on a 1600X1200resolution and the stretch is to 1024 the line thins from 2 pixels to 1, but on a lower screen resolution the line dissapears completely. since the markers are sort of crosshairs, it's a real problem i can't ignore. I tried rounding down the coord value to prevent this, but no good, so if anybody has encountered this before i'd love to hear about it .
thanks
grizli
|
|
|
|
|
Hi,
to get the best results when the overlay contains either lines with fixed thickness (such as cross-hairs) or text, both of which don't scale well, this is what I would try:
1. either don't use an overlay bitmap at all, just draw the overlay in real-time
2. or generate a new overlay bitmap every time the video display gets resized
Both have in common that they should work at the display resolution, not the original video resolution.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 9:16 AM
|
|
|
|
|
How to put the bitmap/image on the button.
thanks
|
|
|
|
|
Button has Image propery. Use it.
|
|
|
|
|
Hiii
I am developing one window application in c# and .net with sql server 2005 as database.
now, i have Four questions:
1] I have one dropdownlist in form and i want to fetch the content/data of table category in to this dropdownlist and when I run this form on clicking dropdownlist the data should be displayed in dropdownlist.
2] As i said one dropdownlist is there and also one textbox is there in this form , now i am selecting one value from dropdownlist and entering keyword or text in textbox and pressing button search, on click event of this button it should compare the dropdownlist and textbox and depending upon the comparision the result should be display in datagridview. the value of dropdownlist and textbox are the data member of table Product
and result should be fetch in datagridview from this table "Product"
3] In Web application we have file uploader control so how we can provide file upload facility in window application?
4] How We can make search of particular keyword in PDF files?
I am really frustating by this questions and my project arrived at the deadline please help me!
I hope You will Help me in good way! Thanx in Advance.
|
|
|
|
|
1 and 2 are pretty trivial. It's obvious that 3 and 4 and totally beyond you. I recommend that in future you learn the language/platform you're paid to code in, instead of asking people to do your work for you after the deadline expires.
For number 1 and 2, I can only say, learn to use google and buy a book. They are both trivial.
For 3 - a web app is already connected to the server. Your app is not. The easiest way to do this, is to create a web service on the server that takes the information of a file, and then use that to send files to your server.
For 4 - you need to buy a PDF library.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Digubha wrote: my project arrived at the deadline please help me
Be patient. Deadlines come and go. Nothing to worry about.
Do your work yourself.
|
|
|
|