PDA

View Full Version : مشکل در فراخوانی تابع



mahdi bg
جمعه 23 آذر 1386, 19:50 عصر
سلام
من یک تابع تعریف کردم با پارامتر های زیر
ولی وقتی توی main اونو فراخوانی می کنم این پیغام خطلا رو میده مشکل کجاست

http://i19.tinypic.com/82a32c5.jpg

ممنون

اَرژنگ
شنبه 24 آذر 1386, 02:35 صبح
private static void createnumber( int[] numbers, int count, int max, int[] z, int m)

mahdi bg
شنبه 24 آذر 1386, 05:06 صبح
سلام
چرا باید این کار رو بکنم؟
ممنون

sinpin
شنبه 24 آذر 1386, 07:52 صبح
سلام
چرا باید این کار رو بکنم؟
ممنون

چون در یک متد استاتیک(Class Level) قصد فراخونی یک متد غیراستاتیک(Object Level) رو داشتید.

sinpin
شنبه 24 آذر 1386, 07:58 صبح
منبع :‌http://www.blackwasp.co.uk/CSharpStaticBehaviour.aspx (http://www.blackwasp.co.uk/CSharpStaticBehaviour.aspx)

It is important to understand that static methods may not directly use non-static members. It is invalid for one static method to directly call a non-static method or property without first instantiating an object. Similarly, private variables that are not marked as static cannot be utilised by a static method. The reverse of this is not true of course, as a non-static member can call a static method.