Autor Beitrag
dragi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 88



BeitragVerfasst: Mi 29.03.06 08:34 
Hallo,

kann mir jemnad sagen wie ich aus
ausblenden Quelltext
1:
Wert = '1'					


in eine Variable Wert habe und in einer zweiten Variable 1. Vor allem wie ich diese Hochkommata loswerde?

Danke

Dragi
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6386
Erhaltene Danke: 146

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Mi 29.03.06 09:37 
Von welchem Typ ist denn Wert?
Ist es ein numerischer Typ, dann kannst du Wert.ToString() benutzen, um den String zu bekommen.
Ist es ein String-Typ nimm z.B. Convert.ToInt32(Wert).
Coreyl
ontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 26

XPP
VS 05, TextEditor
BeitragVerfasst: Mi 29.03.06 09:42 
wenn du dann einen string hast, dann such in der msdn mal nach "substring", damit kann man einen string aufteilen in beliebigen arten.
aber:

string Wert = "1"; // hier wird WERT der wert 1 zugeordnet (eins!) und zwar ohne die Klammern. also überprüf ob du nicht schon das hast was du brauchst (console.write(wert) // gibt den inhalt von wert zurück)

_________________
Von allen Dingen die mir Verloren gegangen, bin ich am meisten an meinem Verstand gehangen
Robert_G
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 416


Delphi32 (D2005 PE); Chrome/C# (VS2003 E/A, VS2005)
BeitragVerfasst: Mi 29.03.06 13:46 
Wenn du die Werte eines Objektes in der DFM von gestern auslesen willst wäre sowas hier möglich:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
(?<Property>
  \w*
)
\s?\=\s?
(?<ValueSection>
  (?<QuotedValue>
    \'
    (?<Value>
      (
        [^\']
        |
        (
          \'\'
        )
        |
        (
          \'\#\d+\'
        )
      )+
    )
    \'
  )
  |
  (?<Value>
    \w*
  )
)


ausblenden volle Höhe C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
static string ReplaceEscapeCharacter(Match match)
{
  byte ordinal;
  if (match.Groups["Ascii"].Success &&
      byte.TryParse(match.Groups["Ascii"].Value, out ordinal))
    return ((Char)ordinal).ToString();
  else
    return match.Value;
}

static string CleanUpValue(string value)
{
  return Regex.Replace(value,
                       @"\'\#(?<Ascii>\d+)\'?",
                       ReplaceEscapeCharacter)
        .Replace("\'\'"
                 "\'");
}

static void Main()
{
  DfmValuesRegex regex = new DfmValuesRegex();
  Dictionary<stringstring> propertyValues = new Dictionary<stringstring>();

  foreach (Match match in regex.Matches(File.ReadAllText("Testfile.txt")))
  {
    if (match.Groups["Property"].Success &&
        match.Groups["ValueSection"].Success)
    {
      string propertyName  = match.Groups["Property"].Value;
      string propertyValue = match.Groups["Value"].Value;

      propertyValues.Add(propertyName, CleanUpValue(propertyValue));
    }
  }

  foreach (KeyValuePair<stringstring> property in propertyValues)
  {
    Console.WriteLine("{0} = {1}", property.Key, property.Value);
  }
}



Für sowas kann ich den Regulator empfehlen. :)
Einloggen, um Attachments anzusehen!
Kha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3803
Erhaltene Danke: 176

Arch Linux
Python, C, C++ (vim)
BeitragVerfasst: Mi 29.03.06 17:37 
user profile iconRobert_G hat folgendes geschrieben:
Für sowas kann ich den Regulator empfehlen. :)

Wow, was für ein Tool :) .
Bisher habe ich nur kleine Programme ähnlich wie das #d-Addin gesehen, aber das Ding ist ja schon fast eine eigene IDE :zustimm: .

[edit] Dass es zusätzlich noch auf .NET zugeschnitten ist, macht es natürlich noch genialer. [/edit]
Robert_G
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 416


Delphi32 (D2005 PE); Chrome/C# (VS2003 E/A, VS2005)
BeitragVerfasst: Mi 29.03.06 18:06 
user profile iconKhabarakh hat folgendes geschrieben:
Wow, was für ein Tool :) .
Bisher habe ich nur kleine Programme ähnlich wie das #d-Addin gesehen, aber das Ding ist ja schon fast eine eigene IDE :zustimm: .


Es IST eigentlich #d, zumindest der #d Editor. :mrgreen:

Zitat:
Dass es zusätzlich noch auf .NET zugeschnitten ist, macht es natürlich noch genialer.
Man kann halt easy komplexe Regechsen in eine Assembly kompostieren.
Im AfterBuild schnell noch ge-IlMerge-t und nacher sieht keiner mehr dass du da eine extra RegEx Assembly< hattest :)