עבור לתוכן
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.

משנה תווי שגדול מ1 ב C# עזרה

Featured Replies

פורסם

שלום,

בניתי תוכנית כחלק מאחת התוכניות שהתבקשתי לבנות

התוכנית היא: להגריל מספר בין 1 ל13 ולהגריל צורה של הקלף : לב ,תלתן,מעוין או עלה

ונתקלתי בבעיה:

using System;
public class Klaf
{
public static void Main()
{
int MisparKlaf;
int TzuratKlaf;
char TzuratKlaf1;


Random rnd = new Random();
MisparKlaf = rnd.Next(1,14);
TzuratKlaf = rnd.Next(1,5);

if (TzuratKlaf == 1)
TzuratKlaf1 = 'Lev';
else if (TzuratKlaf == 2)
TzuratKlaf1 = 'Teltan';
else if (TzuratKlaf == 3)
TzuratKlaf1 = 'Meuyan';
else
TzuratKlaf1 = 'Ale';

Console.WriteLine("The Number of the Card is {0} and the type of the card is {1}",MisparKlaf,TzuratKlaf1);
} // Main
} // class Klaf

התוכנית לא רוצה לרוץ, אבל נגיד שאני שם משתנים עם ערך תווי אחד כמו "A" או "B" התוכנית עובדת לי מצוין ובמקום צורת הקלף הוא פולט לי מ A עד D לפי ההגרלה.

השאלה שלי, למה זה ככה? ואיך אני אעשה שזה יעבוד לי עם צורות הקלפים ולא רק עם "A" ו "B"

תודה :)

פורסם

char מייצג תו אחד.

אתה צריך להשתמש ב-string.

להבא, תרשום גם את הודעת השגיאה של המהדר.

פורסם
  • מחבר

להחליף את char ב string?

ניסיתי עדיין רושם לי את השגיאה כמו מקודם : "Too many characters in character literal "

פורסם

כשאתה רוצה לבצע השמה למחרוזת אתה צריך להשתמש ב " ולא ב '

כלומר:

TzuratKlaf1 = "Lev";

ולא:

TzuratKlaf1 = 'Lev';

פורסם
  • מחבר

אחלה הצלחתי.

תודה שניצל וgoniak

;D

ארכיון

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

דיונים חדשים

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.