تبلیغات
مرجع عملی و کاربردی زبان سی شارپ ، تصاویر دیدنی ، دانلود نرم افزار های گوناگون - اصول اولیه OOP و دات نت فریمورک

اصول اولیه OOP و دات نت فریمورک

نویسنده :مرتضی عالمین
تاریخ:پنجشنبه 31 اردیبهشت 1388-04:53 ب.ظ

1-مفاهیم بنیادین شیء گرایی

1-4-بازتاب Reflection

کار با اشیاء بوسیله ی نام آنها (با کمک از Reflection)


مثال - نمایش یک فرم با دانستن نام آن :
(
این مثال کاربردهای زیادی میتواند داشته باشد، فرض کنید که نام فرمهای مورد نیاز برای کاربردی خاص رو در یک جدول دیتابیس ذخیره کرده اید)

کد:

using System.Reflection;

کد:

private void button1_Click(object sender, EventArgs e)

{

    Assembly myAssembly = Assembly.GetExecutingAssembly();

    Form myForm =

        myAssembly.CreateInstance("WindowsFormsApplication1.Form2") as Form;

    myForm.ShowDialog();

}

نکته : حتما نام NameSpace را قبل از نام آبجکت قرار دهید؛ در مثال بالا "WindowsFormsApplication1" بود.

1-4-Exceptions

جلوگیری از رخ دادن Unhandled Exceptions


در فایل program.cs مربوط به پروژه بعد از دستورات زیر

کد:

Application.EnableVisualStyles();

Application.SetCompatibleTextRenderingDefault(false);

دستور زیر رو قرار بدید

کد:

Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);

و در همون فایل program.cs متدی با همان نامی که در سازنده بالا دادید باید ایجاد کنید مثل متد زیر

کد:

static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)

{

    MessageBox.Show("خطا در اجرای دستور کاربر", "خطا");

}

از این به بعد در صورتی که خطایی در قطعه کدی از برنامه رخ بده که درون بلوک try قرار نداشته باشه به این متد فرستاده می شه و دیگه پیام پیش فرض دات نت فریم ورک نمایش داده نمی شه.
نکته : آرگومان e در متد فوق حاوی Exception ایجاد شده می باشد که از آن می توان استفاده های مختلفی کرد.




داغ کن - کلوب دات کام
نظرات() 
How much does it cost for leg lengthening?
شنبه 1 مهر 1396 04:13 ب.ظ
I'm amazed, I must say. Seldom do I encounter
a blog that's both educative and amusing, and let me tell you, you have hit the nail on the head.

The issue is an issue that too few men and women are speaking intelligently about.
Now i'm very happy I stumbled across this in my hunt for something relating
to this.
What makes you grow taller during puberty?
جمعه 17 شهریور 1396 09:04 ق.ظ
Thank you for the good writeup. It in truth was once a leisure account it.
Glance complex to far added agreeable from you! By the way, how can we keep up a correspondence?
Foot Complaints
دوشنبه 16 مرداد 1396 07:57 ب.ظ
It is appropriate time to make some plans for the future and it is time to be happy.

I've read this post and if I could I wish to suggest
you few interesting things or advice. Maybe you could write
next articles referring to this article. I
wish to read more things about it!
claytontlbpunubzu.jimdo.com
یکشنبه 15 مرداد 1396 05:13 ب.ظ
Magnificent goods from you, man. I've understand your stuff previous to and you're just extremely excellent.
I actually like what you have acquired here, certainly like what you're stating and
the way in which you say it. You make it enjoyable and you still take care of
to keep it sensible. I can't wait to read much more from you.

This is really a great site.
What causes pain in the back of the heel?
یکشنبه 15 مرداد 1396 02:44 ق.ظ
You actually make it appear really easy with your presentation however I find this matter to be actually one thing that I
believe I'd by no means understand. It sort of feels
too complex and extremely broad for me. I am looking forward for your next publish, I will try to get
the grasp of it!
http://providenciasittner.jimdo.com
جمعه 13 مرداد 1396 11:51 ق.ظ
I am not sure where you are getting your
info, but good topic. I needs to spend some time learning more
or understanding more. Thanks for magnificent information I was
looking for this information for my mission.
mirnawardrup.wordpress.com
جمعه 6 مرداد 1396 10:55 ب.ظ
I'm gone to say to my little brother, that he should also pay a visit
this website on regular basis to obtain updated from latest
gossip.
What do you do when your Achilles tendon hurts?
چهارشنبه 4 مرداد 1396 07:44 ب.ظ
When some one searches for his required thing, so he/she needs to be available that
in detail, therefore that thing is maintained over here.
BHW
جمعه 25 فروردین 1396 01:04 ب.ظ
You are so cool! I do not think I have read through a single thing like this
before. So great to find another person with a few genuine thoughts
on this subject. Really.. thanks for starting this up.
This web site is one thing that is required on the internet, someone with a bit of originality!
BHW
پنجشنبه 24 فروردین 1396 05:20 ق.ظ
Incredible story there. What happened after? Thanks!
manicure
دوشنبه 21 فروردین 1396 11:02 ب.ظ
I've been surfing online more than three hours today, but I never found any fascinating article
like yours. It's beautiful value sufficient for me. Personally, if all site owners and bloggers made good content
material as you did, the net will probably be much more useful
than ever before.
manicure
پنجشنبه 17 فروردین 1396 05:59 ق.ظ
I'm not sure why but this weblog is loading very slow
for me. Is anyone else having this issue or is it a problem on my
end? I'll check back later on and see if the problem still exists.
MrSharif
پنجشنبه 31 اردیبهشت 1388 10:28 ب.ظ
وب لاگ باحالی داری خوشحال میشم به جمع ما بپیوندی ما یک انجمن کاملا تخصصی که در اون سرویس وی پی ان رایگان داده میشه و همچنین سرویس مستقیم کننده لینک رو هم به صورت کاملا رایگان از رپیدشر مگا آپلود رو دارا هستیم vpn raygan www.online-dl.com/vpn
yahoo id: kfwu_Test
MrSharif From Ahwaz
 
لبخندناراحتچشمک
نیشخندبغلسوال
قلبخجالتزبان
ماچتعجبعصبانی
عینکشیطانگریه
خندهقهقههخداحافظ
سبزقهرهورا
دستگلتفکر




Admin Logo
themebox Logo