|
I checked in the Program.cs and the [STAThread] has been set. It is a windows application that needs to execute methods from an external dll...
Illegal Operation
|
|
|
|
|
Hello everyone,
Sorry for this stupid question, as I am migrated from C++ to C#. In C++ there is no concept of property, except in COM.
For static property of a class in C# (e.g. DateTime.Now), I think there is nothing special compared to a non-static property, except we need to access the property by class name other than by instance variable name?
In my usage of static property, I feel no special point compared with static function. Correct?
thanks in advance,
George
|
|
|
|
|
You know properties are getter and setters and compiled into normal methods. Say you have property named "MyProperty" which will be compiled into get_MyProperty() and set_MyProperty() .
Non-static members are instance members which requires an instance for accessing. Statics are class members and can be accessed directly.
|
|
|
|
|
Thanks N a v a n e e t h,
Besides get/set methods, static property behaves the same like static member function?
regards,
George
|
|
|
|
|
Yes.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Good to learn from you Greeeg!
regards,
George
|
|
|
|
|
static in C# is the same as C++. It's just a matter of scope.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks Chris!
Christian Graus wrote: a matter of scope
Means?
regards,
George
|
|
|
|
|
George_George wrote: In my usage of static property, I feel no special point compared with static function. Correct?
Properties help avoid adding a getter and setter function for every field that you want to expose - the resulting design looks cleaner, IMO.
|
|
|
|
|
|
George_George wrote: In my usage of static property, I feel no special point compared with static function. Correct?
In fact, DateTime.Now evaluates to public static DateTime get_Now() , so it's just a static get method. You can examine this in .NET Reflector.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
|
Hello everyone,
Here is my test program. I want to confirm that when we pass an out variable into a function, we just pass a reference, no additional copy is made?
class Program
{
struct Foo
{
public int abc;
}
static void Test(out Foo f)
{
f.abc = 200;
return;
}
static void Main(string[] args)
{
Foo f1;
f1.abc = 100;
Test(out f1);
Console.WriteLine(f1.abc);
return;
}
}
thanks in advance,
George
|
|
|
|
|
You will get 200. What's the problem here ? If you remove out , you will get 100.
|
|
|
|
|
Yes, N a v a n e e t h!
I got 200. I just want to confirm that when we pass an out variable into a function, we just pass a reference, no additional copy is made?
regards,
George
|
|
|
|
|
Yes the reference is passed and no additional copy is made.
|
|
|
|
|
Thanks N a v a n e e t h,
Question answered.
regards,
George
|
|
|
|
|
I have to do some animation (slide in / slide out) on about 5 images in c# form. For this I have placed a transparent form on which 5 panel with background images and initially set their location out of form so that they will be invisible at start. On start called a routine, which brings those into the form with slide effect. The routine is
-------------------------------------------------code-------------------------------------
void inimationStart()
{
if (this.Visible)
{
panel1.SetBounds(-300, panel1.Location.Y, panel1.Width, panel1.Height);
panel3.SetBounds(-360, panel3.Location.Y, panel3.Width, panel3.Height);
panel4.SetBounds(-400, panel4.Location.Y, panel4.Width, panel4.Height);
panel5.SetBounds(-460, panel5.Location.Y, panel5.Width, panel5.Height);
panel6.SetBounds(-500, panel6.Location.Y, panel6.Width, panel6.Height);
panel2.SetBounds(-560, panel2.Location.Y, panel2.Width, panel2.Height);
this.Refresh();
MessageBox.Show(this.Width.ToString());
for (int i = 0; i < 560; i += 20)
{
if (i < 300)
panel1.SetBounds(panel1.Location.X + 20, panel1.Location.Y, panel1.Width, panel1.Height);
if (i < 360)
panel3.SetBounds(panel3.Location.X + 20, panel3.Location.Y, panel3.Width, panel3.Height);
if (i < 400)
panel4.SetBounds(panel4.Location.X + 20, panel4.Location.Y, panel4.Width, panel4.Height);
if (i < 460)
panel5.SetBounds(panel5.Location.X + 20, panel5.Location.Y, panel5.Width, panel5.Height);
if (i < 500)
panel6.SetBounds(panel6.Location.X + 20, panel6.Location.Y, panel6.Width, panel6.Height);
if (i < 560)
panel2.SetBounds(panel2.Location.X + 20, panel2.Location.Y, panel2.Width, panel2.Height);
this.Refresh();
}
}
} ----------------------------------------------------------------------------------------
But here I cought in few problems
1. when I make the form visible all the panels are visible on the form and then suddenly disappear, whereas I have disappeared those.
2. It’s very slow.
3. some flickering
Could anybody please help me? Thanks.
abrar
|
|
|
|
|
Rather than shifting a bunch of panels, i recomend you just draw the images yourself. To get rid of flickering use double buffering. I forget exactly how you do that, but it should be an option in the designer (for your form) and its pretty easy to google.
You'll want to be drawing the images in your forms OnPaint event, and this is quite simple. You will also need a way to track the location of your pics though and you should use a timer to change these variables so that you get smooth motion, something like this perhaps:
Time myTimer = ...;
myTimer.Interval = 100;
Bitmap imageOne = ...;
int xOne,yOne;
Bitmap imageTwo = ...;
int xTwo,yTwo;
...
void OnPaint(PaintEventArgs e)
{
e.Graphics.DrawImageUnscaled(imageOne, xOne, yOne);
e.Graphics.DrawImageUnscaled(imageTwo, xTwo, yTwo);
}
void TimerTick(object sender, EventArgs e)
{
if(xOne < XX)
xOne += 20;
if(xTwo < XX)
xTwo += 20;
this.Invalidate();
}
EDIT: If you use a timer like this and it's still too jumpy, then you're gonna need to use a better timer that the one .Net supplies. Your gonna need to go back in time to timeSetEvent and timeKillEvent from winmm.dll
My current favourite word is: I'm starting to run out of fav. words!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
Hi all
I am developing a Voice Chat Application.....
I used DirectSound For Capturing the Audio. Using WaveFormat I am capturing the audio bytes and sending it over the client.....
My client is receiving the Audio Byte...But it is not playing.......
Can anyone tell me what will be the reason.......
Thanks in Advance
Vayanan
|
|
|
|
|
vayanan wrote: Can anyone tell me what will be the reason.......
Their volume is turned off.
Seriously, it's hard to tell if you don't give us more detail. How are you trying to play it ? Is it stored in a file first ? What does the code look like ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I need a code generator which will generate class for my Table adapter (which has insert update delete fillby etc methods). I have tried CodeSmith seems not working with the tnsnames.ora conn string.
If there is any other alternate solution that is also welcomed.
Thanks,
|
|
|
|
|
I don't use Oracle (I downloaded it once and it ground my PC to a halt!), but does any of this stuff[^] from their site help?
Dave
|
|
|
|
|
May be I couldn't express it correctly. I need a c# code for codegenerator which is going to generate code for my Data Access Objects, one like CodeSmith etc does. I have code ready for objects but have to get it for writing Insert update Delete method. I mentioned oracle as most of the tools work good for MSSQL.
Hope you got it!
|
|
|
|
|
Anything here[^] help ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|