conversion dictionary C++ en C#
Bonjour,
Etant débutant en prog, j'ai créer (grâce à certain membres du forum C++) une application en C++ CLI avec visual studio 2005, celle-ci tourne bien sur PC mais je voudrai l'utiliser sur mon pocket PC (Windows mobile 6).
Pour se faire il me faut coder la même appli en C# .
Après plusieurs heures passé je n'y arrive toujours pas :( .
Il s'agit d'un dictionaire dont voici un extrait du code C++ :
Code:
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 42 43 44 45 46 47 48 49 50 51 52 53 54
|
#include <iostream>
#include <string>
#include "FourStrings.h"
namespace dico{
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Collections::Generic;
using namespace System::Text;
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
dict = gcnew Dictionary< String^, FourStrings^ >;
FourStrings ^FourStrs = gcnew FourStrings;
FourStrs->first = L"arbre à feuille";
FourStrs->second = L"";
FourStrs->three = L"";
FourStrs->four = L"";
dict->Add(L"A12", FourStrs);
private:
Dictionary< String^, FourStrings^ > ^ dict;
#pragma endregion
private: System::Void textBox1_TextChanged(System::Object^ sender, System::EventArgs^ e) {
String^ a = textBox1->Text;
FourStrings ^FourStrs;
if(dict->TryGetValue(a, FourStrs)&&(FourStrs->three != "")) // si dans dictionary j'ai la tkey == a
{
textBox2->Text = FourStrs->first;// j'affiche la Tvalue first
textBox3->Text = FourStrs->second; // j'affiche la Tvalue second
}
else if (dict->TryGetValue(a, FourStrs))
{
textBox2->Text = FourStrs->first;// j'affiche la Tvalue first
textBox3->Text = FourStrs->second; // j'affiche la Tvalue second
}
else
{
textBox2->Text = L" \r\n Abreviation Inconnue ";
} |
Et dans un autre fichier d'en-tête.h la classe FourStrings
Code:
1 2 3 4 5 6 7 8 9 10 11 12
|
namespace dico {
using namespace System;
public ref class FourStrings {
public:
String^ first;
String^ second;
String^ three;
String^ four;
};
} |
Merci de votre aide, bonnes fête à tous