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.

C# string.Format Problem

Empfohlene Antworten

Veröffentlicht

Hi,

habe das Problem das mir das Programm hier immer abstürtzt. Eigentlich sollte doch alles stimmen, oder? ^^

    foreach (DtoInventar inventar in abfrageInventar)

            {

            // befüllen der txt.Datei

               zeile = string.Format("{0,-7}{1,-30}{2,-30}{3,-20}{4,-30}{5,-30}{6,-7}{7,-10}{8,-10}{9,-13}{10,-30}{11,-30}{12,-30}{13,-30}{14,-1}{15,-6}{16,-6}{17,-70}{18,-20}{19,-20}{20,-20}{21,-20}{22,-20}{23,-20}{24,-20}{25,-20}{26,-20}{27,-20}{28,-7}", standort.NUMMER, standort.BEZEICHNUNG, inventar.VORGAENGERSTANDORT, inventar.INVENTAR, inventar.CODE, inventar.ANLAGEGUT, inventar.NUMMER, inventar.DATUM, inventar.KOSTEN, inventar.VERANTWORTLICHER, inventar.BEZEICHNUNG, inventar.BEZEICHNUNG2, inventar.BEZEICHNUNG3, inventar.ETIKETT, inventar.MENGE, inventar.GRUPPEKZ, inventar.GRUPPE, inventar.GRUPPENFELD1, inventar.GRUPPENFELD2, inventar.GRUPPENFELD3, inventar.GRUPPENFELD4, inventar.GRUPPENFELD5, inventar.GRUPPENFELD6, inventar.GRUPPENFELD7, inventar.GRUPPENFELD8, inventar.GRUPPENFELD9, inventar.GRUPPENFELD10, inventar.ANLAGEGUTKEY);


               writer.WriteLine(zeile);

            }

Bitte um Hilfe.

EDIT: Bekomme immer diese Fehlermeldung ( Exception )

Der Index, basierend auf 0 (null), muss größer als oder gleich Null sein, und kleiner als die Größe der Argumentenliste.
- FormatException

Bearbeitet von Max1809

Mal abgesehen von der aktuellen Fehlerlage - was spricht gegen Folgendes?


StringBuilder zeile = new StringBuilder();

zeile.AppendFormat("{0,-7}", standort.NUMMER);
[...]
writer.WriteLine(zeile.ToString());
[/PHP]

So wird die Zeile nicht übermäßig lang und du siehst eher, wo der Hase im Pfeffer liegt. Btw. stellt sich die Frage, ob es nicht sinnvoll wäre, die Daten anders zu serialisieren?

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

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.