PDA

View Full Version : سوال: چند سوال درباره component



ashton
چهارشنبه 16 فروردین 1391, 04:13 صبح
اگه زحمت نيست درباره مورد هاي زير كمي توضيح ميخواستم.
١. component چيست.
٢. clr چيست.
٣. بسته مقداري value type چيست.
٤. مرجع reference چيست.

با تشكر
خيلي لازم دارم

banitaba.ommolketab
چهارشنبه 16 فروردین 1391, 07:29 صبح
1- component رو میتونی یک کلاس آماده فرض کنی ، که میتونی اون را توی پروژه های مختلف استفاده کنی . چیزی که در عرف جا افتاده اینه که component را بیشتر به عنوان کنترل های مختلف با کاربری های مختلف میشناسند. به طور کلی برای دستیابی به ابزار بیشتر جهت برنامه نویسی از component هایی که توسط افراد و شرکت های گوناگون طراحی میشه استفاده میشود.
_________________
2- نمی دانم
________________
3- value type خیلی سادس ، اگه همین کلمه را معنی کنی یعنی نوع داده ، که این نوع میتونه string , integer , real و ... باشه، فکر نمیکنم توضیح بیشتری لازم باشه.
________________
4- این سوال هم که کاملا مشخصه عزیز من ، توی هر زمینه ای از جمله برنامه نویسی بعضی افراد ، بعضی کتابها به عنوان مرجع یا reference شناخته می شوند. که سخن اون فرد یا نوشته سند محسوب میشه و هرکسی میتونه به اون استناد کنه.

Sirwan Afifi
چهارشنبه 16 فروردین 1391, 08:16 صبح
CLR: یه محیط زمان اجرا که برنامه های دات نت تحت اون اجرا میشن این محیط وظایف همچون : مدیریت حافظه،ایمنی نوع و مدیریت اسثناها و .... را ارائه می دهد برای توضیحات بیشتر به اینجا (http://en.wikipedia.org/wiki/Common_Language_Runtime)نگاه کنید.

crazy coder
چهارشنبه 16 فروردین 1391, 08:35 صبح
اگه زحمت نيست درباره مورد هاي زير كمي توضيح ميخواستم.

٣. بسته مقداري value type چيست.
٤. مرجع reference چيست.

با تشكر
خيلي لازم دارم
سلام
روز بخیر خدا قوت
سوال زیبایی پرسیدی... وقتی تو برنامه نویسی به مشکلی برخوردی که مجبور شدی این سوال رو بپرسی یعنی داری برنامه نویس بزرگی و مفهوم گرایی میشی...
این متن رو بخون اگه سوالی داشتی من درخدمتم...
خوب ...نوع داده های ساده رو (simple data tuype) رو value type میگن در حالی که کلاس ها (classes) رو refrence type میگن.
در valu type ها ساختار ساده ای وجود دارد که در آنها مقدار ذخیره میشه مثلا int که مقدار 7 رو در اون ذخیره میکنیم
اما در refrence type ها ما به یک قسمت از حافظه اشاره میکنیم که ساختار ساده ای نداره
معمولا دات نت تلاش میکنه که این دو نوع برای ما تفاوتی در برنامه نویسی ایجاد نکنه ...اما گاهی اوقات لازمه که ما بدونیم تو لایه های پایینی چه خبره...
این دونوع در موارد زیر باهم تفاوت دارن که شما در برنامه نویسی باید دقت لازم رو تو این موارد داشته باشی...
-assignment
-comparison
-passing parameters
حالا چون توضیح هر کدوم مفصله شما بفرمایین کدوم مورد رو نیاز داری تا من خدمت شما توضیح بدم...
من توضیح هر مورد رو به در پایین گذاشتم . اگه سوالی بود من در خدمتم
در پناه خدا

crazy coder
چهارشنبه 16 فروردین 1391, 08:37 صبح
Assignment Operations
When you assign a simple data variable to another simple data variable, the contents of the
variable are copied:
integerA = integerB; // integerA now has a copy of the contents of integerB.
// There are two duplicate integers in memory.
Reference types work a little differently. Reference types tend to deal with larger amounts
of data. Copying the entire contents of a reference type object could slow down an application,
particularly if you are performing multiple assignments. For that reason, when you
assign a reference type you copy the reference that points to the object, not the full object
content:
// Create a new Product object.
Product productVariable1 = new Product();
// Declare a second variable.
Product productVariable2;
productVariable2 = productVariable1;
// productVariable1 and productVariable2 now both point to the same thing.
// There is one object and two ways to access it.
The consequences of this behavior are far ranging. This example modifies the Product
object using productVariable2:
productVariable2.Price = 25.99M;
You’ll find that productVariable1.Price is set to 25.99. Of course, this only makes sense
because productVariable1 and productVariable2 are two variables that point to the same
in-memory object.
If you really do want to copy an object (not a reference), you need to create a new object,
and then initialize its information to match the first object. Some objects provide a Clone()
method that allows you to easily copy the object. One example is the DataSet, which is used to
store information from a database.
Equality Testing
A similar distinction between reference types and value types appears when you compare two
variables. When you compare value types (such as integers), you’re comparing the contents:
if (integerA == integerB)
{
// This is true as long as the integers have the same content.
}
When you compare reference type variables, you’re actually testing whether they’re the
same instance. In other words, you’re testing whether the references are pointing to the same
object in memory, not if their contents match:
CHAPTER 3 n TYPES, OBJECTS, AND NAMESPACES 67
if (productVariable1 == productVariable2)
{
// This is true if both productVariable1 and productVariable2
// point to the same thing.
// This is false if they are separate, yet identical, objects.
}
nNote This rule has a special exception. When classes override the == operator, they can change what
type of comparison it performs. The only significant example of this technique in .NET is the String class. For
more information, read the sidebar “Would the Real Reference Types Please Stand Up?” later in this chapter.
Passing Parameters by Reference and byValue
You can create three types of method parameters. The standard type is pass-by-value.When
you use pass-by-value parameters, the method receives a copy of the parameter data. That
means that if the method modifies the parameter, this change won’t affect the calling code.
By default, all parameters are pass-by-value.
The second type of parameter is pass-by-reference.With pass-by-reference, the method
accesses the parameter value directly. If a method changes the value of a pass-by-reference
parameter, the original object is also modified.
To get a better understanding of the difference, consider the following code, which shows
a method that uses a parameter named number. This code uses the ref keyword to indicate
that number should be passed by reference. When the method modifies this parameter (multiplying
it by 2), the calling code is also affected:
private void ProcessNumber(ref int number)
{
number *= 2;
}
The following code snippet shows the effect of calling the ProcessNumber method. Note
that you need to specify the ref keyword when you define the parameter in the method and
when you call the method. This indicates that you are aware that the parameter value may
change:
int num = 10;
ProcessNumber(ref num); // Once this call completes, Num will be 20.
The way that pass-by-value and pass-by-reference work when you’re using value types
(such as integers) is straightforward. However, if you use reference types, such as a Product
object or an array, you won’t see this behavior. The reason is because the entire object isn’t
passed in the parameter. Instead, it’s just the reference that’s transmitted. This is much more
efficient for large objects (it saves having to copy a large block of memory), but it doesn’t
always lead to the behavior you expect.
68 CHAPTER 3 n TYPES, OBJECTS, AND NAMESPACES
One notable quirk occurs when you use the standard pass-by-value mechanism. In this
case, pass-by-value doesn’t create a copy of the object, but a copy of the reference. This reference
still points to the same in-memory object. This means that if you pass a Product object to
a method, for example, the method will be able to alter your Product object, regardless of
whether you use pass-by-value or pass-by-reference.