ich die c las ++ 's foreach Syntax auf MSDN:String^MyString = gcnew String ("abcd");
// for_each_string1.cpp
// compile with: /ZW
#include <stdio.h>
using namespace Platform;
ref struct MyClass {
property String^ MyStringProperty;
};
int main() {
String^ MyString = ref new String("abcd");
for each (char c in MyString)
wprintf("%c", c);
wprintf("/n");
MyClass^ x = ref new MyClass();
x->MyStringProperty = "Testing";
for each(char c in x->MyStringProperty)
wprintf("%c", c);
}
Ich habe versucht, was die "^" auf Google bedeutet, zu finden, aber ich konnte nichts finden (oder meine Frage nicht korrekt war)
Was bedeutet das? Ist es wie ein "*"? Ist es als "&"?
Diese Syntax gilt auch für C#. Bedeutet das in beiden Sprachen dasselbe?
Stück C# code:
using namespace System;
int main(){
array<int>^ arr = gcnew array<int>{0,1,2,5,7,8,11};
int even=0, odd=0;
for each (int i in arr) {
if (i%2 == 0)
even++;
else
odd++;
}
Console::WriteLine(“Found {0} Odd Numbers, and {1} Even Numbers.”,
odd, even);
}
Dies ist nicht C++, es ist Microsoft proprietäre Sprache, C++/CLI. –
Dies ist nicht C++, es ist C++/CLI. –
DirectX verwendet dies auch. Was heißt das überhaupt? – Felix