Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

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.

Empfohlene Antworten

Veröffentlicht

Hallo,

ich arbeite momentan an einem Projekt, bei welchem ich einen char in unterschiedlichen Klassen verwende und sobald er sich in einer Klasse ändert, sollte er sich auch in allen anderen Klassen ändern, jedoch tut er das nicht.

Könnte mir da vielleicht jemand mit helfen?

public static class Holder
{
        public static char SomeChar = 'a';
}
public class Example
{
	public void Print() => Console.WriteLine(Holder.SomeChar);
}
Console.WriteLine(Holder.SomeChar);
var x = new Example();

Holder.SomeChar = 'b';           
x.Print();

Ausgabe:

a
b
Drücken Sie eine beliebige Taste . . .

 

Oder machst du Folgendes:

public class Example
{
  public char HoldedValue { get; } = Holder.SomeChar;
  public void Print() => Console.WriteLine(HoldedValue);
}

 

Console.WriteLine(Holder.SomeChar);
var x = new Example();
Holder.SomeChar = 'b';           
x.Print();

 

Bearbeitet von r4phi

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

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.