|
I think he means the version number that shows up when you right click, select Properties and then the PDF tab.
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)
|
|
|
|
|
DaveyM69 wrote: I think he means the version number that shows up when you right click...
Rule #1 in troubleshooting: You either "know" or you don't. "Thinking" is not allowed.
|
|
|
|
|
Note to self... Stop thinking.
There, that's that done
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 want to khnow how i can added a image in database(sql)?
whit forms in c#???
|
|
|
|
|
|
|
Im not sure if this can be done.
But i want to create my on Nullable<t> struct.
my problem is that i cant assign null to my struct as it is an non-nullable type, how can i overcome this ?
Heres my attemt:
[Serializable, StructLayout(LayoutKind.Sequential)]
public struct Null<T> where T : struct
{
private bool hasValue;
private bool allowNull;
internal T value;
public Null(T value)
{
this.value = value;
this.hasValue = true;
this.allowNull = true;
}
public bool HasValue
{
get
{
return this.hasValue;
}
}
public bool AllowNull
{
get
{
return this.allowNull;
}
}
public T Value
{
get
{
if (!this.HasValue)
{
throw new InvalidOperationException("No Value!");
}
return this.value;
}
}
public T GetValueOrDefault()
{
return this.value;
}
public T GetValueOrDefault(T defaultValue)
{
if (!this.HasValue)
{
return defaultValue;
}
return this.value;
}
public override bool Equals(object other)
{
if (!this.HasValue)
{
return (other == null);
}
if (other == null)
{
return false;
}
return this.value.Equals(other);
}
public override int GetHashCode()
{
if (!this.HasValue)
{
return 0;
}
return this.value.GetHashCode();
}
public override string ToString()
{
if (!this.HasValue)
{
return "";
}
return this.value.ToString();
}
public static implicit operator Null<T>(T value)
{
return new Null<T>(value);
}
public static explicit operator T(Null<T> value)
{
return value.Value;
}
}
This is all fine but when i then try to use it i get an non-nullable type exception:
Example:
private Null<int> index = null;
the null; assignment returns the following error:
Error 4 Cannot convert null to 'Null<int>' because it is a non-nullable value type
Can this be done,if so HELP please, or am i on an wrong track here ?
With great code, comes great complexity, so keep it simple stupid...
|
|
|
|
|
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.
|
|
|
|