|
Only unless the method that is using this code is also static... otherwise they dont need to be. From the looks he is testing an internal variable so chances are it wont be static.
Edit: But it could be static even if it wasnt static... could go either way.
|
|
|
|
|
Jammer wrote: bool s = _myProperty == true ? Method1() : Method2();
Why doesn't it work? It should, as long as Method1() and Method2() return bool, or return types convertible to each other and to bool.
|
|
|
|
|
S. Senthil Kumar wrote: or return types convertible to each other and to bool
Good lord, I still remember that post on your blog. I asked a few people, and nobody knew it! I wonder why they made that restriction.
Cheers,
Vikram. Current activities:
Films: Sense and Sensibility
TV series: Friends, season 2
Books: Longitude, by Dava Sobel. Carpe Diem.
|
|
|
|
|
Hi,
I see ... the problem was the methods are void return types. Can this be used with void?
Cheers,
|
|
|
|
|
No, the expression containing the ternary operator must be of some type. If both the methods take no parameters, this will work
Action result = p ? new Action(M1) : new Action(M2);
result();
|
|
|
|
|
Jammer wrote: Is there any way to get the following to work?
bool s = _myProperty == true ? Method1() : Method2();
It should work, if both Method1 and Method2 are static and retrun a Bool value.
|
|
|
|
|
I don't get it, why should the methods be static?
|
|
|
|
|
They dont need to be as I said earlier... i.e.
class Conditional
{
private bool _myProperty;
public bool MyProperty
{
get { return _myProperty; }
set { _myProperty = value; }
}
public bool DoSomething()
{
bool s = _myProperty == true ? Method1() : Method2();
return s;
}
public bool Method1()
{
return true;
}
public bool Method2()
{
return false;
}
}
|
|
|
|
|
sorry on that - I had another issue on my mind when I read the question and posted that. I just thought of how I would stick that in a console app - where method1 & 2 were helpers to Main (ie. methods in the Program class) - in which case static would be required. But on considering.. should have just posted my own question quietly.
---------------------------------------------
Help... I'm embedded and I can't get out!
If they don't get the basic research and learning skills down then they'll end up having a very hard life (Either that or they'll become managers) - Micheal P Butler
|
|
|
|
|
|
Hello there,
Can anyone name me a site where I can download a huge or a limited quantity of icon files (*.ico images)!
Your help will truly be appreciated,
Rajdeep.NET
|
|
|
|
|
Have a Google for free icons, loads of hits. You'll have to select what suits you, for yourself though.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Well I can give you advice If you are using visual basic . net Framework There you can make icon for you .exe files
Here I give you a link they have licence about you can free download there Icons for windows applicacion or what ever you want .
The link :
miloszwl.deviantart.com
|
|
|
|
|
|
Is it possible to somehow pass an image to a report? I have the byte[] but the ReportParameter only takes strings. So how do I pass the byte (which contains an image) and pass it to the report and display the image in the report?
Currently I'm passing this:
ReportParameter[] parameters = new ReportParameter[6];
parameters[0] = new ReportParameter("Tag", this.Tag);
parameters[1] = new ReportParameter("Completed", dateTimeCompleted.Value.ToLongDateString());
parameters[2] = new ReportParameter("HDModel", txtModel.Text);
parameters[3] = new ReportParameter("HDSerial", txtSerial.Text);
parameters[4] = new ReportParameter("HDSize", txtSize.Text);
parameters[5] = new ReportParameter("Signature", GetSig().ToString());
GetSig() gets the bytes:
byte[] GetSig()
{
MemoryStream ms = new MemoryStream();
Bitmap SaveBMP = new Bitmap(panelSig.Size.Width, panelSig.Size.Height);
panelSig.DrawToBitmap(SaveBMP, new Rectangle(0, 0, panelSig.Size.Width, panelSig.Size.Height));
SaveBMP.Save(ms, ImageFormat.Png);
byte[] sigPic = ms.ToArray();
ms.Close();
ms.Dispose();
SaveBMP.Dispose();
return sigPic;
}
But how do I display that in the reportviewer on the report?
|
|
|
|
|
hi
does return form a value such as function ???
|
|
|
|
|
Return[^] simply returns from the method (function). If the method signature specifies a return type then the return needs to return an instance of that type.
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) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
thanks a lot
yes
but where must i write? in witch part??
|
|
|
|
|
Anywhere inside the method where it makes sense.
If the return statement isn't inside some kind of conditional block, anything after it will be unreachable.
You can have multiple return statements in a method by putting them (where appropriate) inside different conditions, but the recommendation is to only have one return - which is normally at the end of the method.
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) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
If what you mean is "Does a form return a value in the same way a function does?", then yes it can:
frmSettings fs = new frmSettings();
if (frmSettings.ShowDialog() == DialogResult.OK)
{
...
}
But if you mean "Can a form return any value at all", then no.
But if you mean "wagga wagga bimmble bim olay-biscuit-barrel", then don't-sleep-in-the-subway-darling.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
If its a custom form, which it is likely to be, then you can just use a property as a 'return value' and access that after closing the form, then it can be anything (well not a cheeseburger of course )
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
OriginalGriff wrote: But if you mean "wagga wagga bimmble bim olay-biscuit-barrel", then don't-sleep-in-the-subway-darling.
I just gave you 5.
But only for that bit, you understand.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hello good fellas
I'm struggling since this morning about this sqlite thing.after reading some good tutorials i decided to use it as my embedded database in my winform application.
i downloaded SQLite-1.0.61.0-setup that install the system.datal.sqlite for me and downloaded the firefox plugin sqlite manager and another management tool called wxSQLitePlus found <a href="http://cfred.free.fr/wxsqliteplus.php">here</a> based on this tutorials found <a href="http://decoding.wordpress.com/2009/01/14/using-sqlite-with-net/">here</a> (just being explicit)
Hoping i'm not posting any stupid stuff that will be ignored, here are my 2 challenges.
the first challenge is that i can't reference the database inside a folder let'say database
i have exception "Unable to open the database file".my app.config is as follow
<code><connectionStrings>
<add name="embcon" connectionString="Data Source=database\iagency.db;Version=3;"/>
</connectionStrings></code>
but if the iagency.db is inside the root folder there is no problem at all.app.config like
<code><connectionStrings>
<add name="embcon" connectionString="Data Source=iagency.db;Version=3;"/>
</connectionStrings></code>
the second chalenge is that object created via tools such as either firefox plugin or wxsqlite+
cannot be queried inside visual studio 2005 that i'm using.if it's a table when queried , i have an excetion the object doesn't exist even though both tools displays the same data.
and inversly table created by queries inside visual studio cannot be viewed by the tools.
so what's the deal?
is it a memory stuff or i'm just missing some points?
can enybody explain what is happening ?Thanks for reading.
eager to learn
|
|
|
|
|
i just wanted to precise that i can connect to the database though the server explorer.and there is no table created from visual studio queries.but the table's data can be displayed on a grid when i run it.weird!!
hanging on your replies, i can't find anything meaningful to my case.thanks
eager to learn
|
|
|
|
|
I have to find a folder from the path where my application exist e.g. c:/programfile/RTGSL/exe/..
then from exe folder i have to copy two folders(with all data) name applicationdata & client from this path to the current logged in user's personal folder path i.e. C:\Documents and Settings\ashishjaiswal\Application Data\clientdata\ if and only if no folder exist at this path..
Can any body help me with this code .. I am really new to programming
|
|
|
|