עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

C# properties

Featured Replies

פורסם

כתבתי שדות בתוך מחלקה:


private bool bex;
public bool Bex
{
set { this.bex = value; }
get { return this.bex; }
} }

וכשאני באה לאתחל אותו בתכנית:

  this.Bex = true;

אני מקבלת את השגיאה הבאה:

An unhandled exception of type 'System.StackOverflowException' occurred in minip.exe

מה הבעיה?

פורסם

את בטוחה שלא התבלבלת בטעות בין אותיות קטנות וגדולות? כלומר, לא עשית משהו כזה בטעות:

private bool bex;
public bool Bex
{
set { this.Bex = value; }
get { return this.Bex; }
}

פורסם

וכדי להמנע מאפילו האפשרות של מצב כזה, מקובל ברוב הקונבנציות התכנות לאסור על מזהים אשר שונים זה מזה רק ב-captilatization.

במקום Bex ו-bex, אפשר לדוגמא Bex ו-m_bex.

פורסם

דווקא ב-#C זה לא ממש נהוג.

(אבל כן, זה אחד החסרונות של properties)

פורסם

דווקא ב-#C זה לא ממש נהוג.

(אבל כן, זה אחד החסרונות של properties)

לפי מה שאתה אומר אז דווקא ב-C# כדאי שזה יהיה נהוג :)

פורסם

אם את עובדת עם visual studio 2008 את יכולה לחסוך הרבה כאב ראש ולהשתמש בסינטקס של auto-property. במקרה הזה מספיק לכתוב

public bool Bex {get; set;}

(זה מחליף את כל מה שכתבת)

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.