none
Equivalence de ce code en VB.net RRS feed

  • Question

  • publicclass Dinosaur

    Bonjour,

    { public string m_Name; public string m_HomeContinent; publicbool m_Carnivore; public uint m_YearsExtinct; publicdouble m_Weight;   public Dinosaur(string Name, string HomeContinent, bool Carnivore, uint YearsExtinct, double Weight) {// Assign to member variables } }

    Comment réaliser l'assignation des variables en VB.net ?

    public Dinosaur(string Name, string HomeContinent, bool Carnivore, uint YearsExtinct, double Weight)

    Merci

    • Type modifié Aurel Bera lundi 21 janvier 2013 09:50 Question
    dimanche 20 janvier 2013 09:23

Réponses

  • J'ai trouvé une page web qui fait cela .

    http://www.developerfusion.com/tools/convert/csharp-to-vb/

    Public Class Dinosaur
    	Public m_Name As String
    	Public m_HomeContinent As String
    	Public m_Carnivore As Boolean
    	Public m_YearsExtinct As UInteger
    	Public m_Weight As Double
    
    			' Assign to member variables
    	Public Sub New(Name As String, HomeContinent As String, Carnivore As Boolean, YearsExtinct As UInteger, Weight As Double)
    	End Sub
    End Class
    
    Public Class SmallerDino
    	Private m_HomeContinent As String
    	Private m_Carnivore As Boolean
    	Private m_Weight As Double
    
    	Public Sub New(HomeContinent As String, Carnivore As Boolean, Weight As Double)
    		m_HomeContinent = HomeContinent
    		m_Carnivore = Carnivore
    		m_Weight = Weight
    	End Sub
    
    	' A couple of properties go here
    
    	Public ReadOnly Property Match() As Predicate(Of Dinosaur)
    		Get
    			Return AddressOf IsMatch
    		End Get
    	End Property
    
    	Private Function IsMatch(dino As Dinosaur) As Boolean
    		Return dino.m_Carnivore = m_Carnivore AndAlso dino.m_HomeContinent = m_HomeContinent AndAlso dino.m_Weight <= m_Weight
    	End Function
    End Class

    • Marqué comme réponse Aurel Bera lundi 21 janvier 2013 09:51
    dimanche 20 janvier 2013 09:45

Toutes les réponses

  • Je vous mets tout l'ensemble autrement cela n'a pas de sens.  C'est sur l'utilisation des predicates.

    Il y a t'il une astuce pour convertir du code Csharp vers VB.net ?

    public class Dinosaur
    {
    	public string m_Name;
    	public string m_HomeContinent;
    	public bool m_Carnivore;
    	public uint m_YearsExtinct;
    	public double m_Weight;
     
    	public Dinosaur(string Name, string HomeContinent, bool Carnivore, uint YearsExtinct, double Weight)
    	{
    		// Assign to member variables
    	}
    }
     
    public class SmallerDino
    {
    	private string m_HomeContinent;
    	private bool m_Carnivore;
    	private double m_Weight;
     
    	public SmallerDino(string HomeContinent, bool Carnivore, double Weight)
    	{
    		m_HomeContinent = HomeContinent;
    		m_Carnivore = Carnivore;
    		m_Weight = Weight;
    	}
     
    	// A couple of properties go here
    
    	public Predicate<Dinosaur> Match
    	{
    		get { return IsMatch; }
    	}
     
    	private bool IsMatch(Dinosaur dino)
    	{
    		return dino.m_Carnivore == m_Carnivore &&
    			dino.m_HomeContinent == m_HomeContinent &&
    			dino.m_Weight <= m_Weight;
    	}
    }

    dimanche 20 janvier 2013 09:41
  • J'ai trouvé une page web qui fait cela .

    http://www.developerfusion.com/tools/convert/csharp-to-vb/

    Public Class Dinosaur
    	Public m_Name As String
    	Public m_HomeContinent As String
    	Public m_Carnivore As Boolean
    	Public m_YearsExtinct As UInteger
    	Public m_Weight As Double
    
    			' Assign to member variables
    	Public Sub New(Name As String, HomeContinent As String, Carnivore As Boolean, YearsExtinct As UInteger, Weight As Double)
    	End Sub
    End Class
    
    Public Class SmallerDino
    	Private m_HomeContinent As String
    	Private m_Carnivore As Boolean
    	Private m_Weight As Double
    
    	Public Sub New(HomeContinent As String, Carnivore As Boolean, Weight As Double)
    		m_HomeContinent = HomeContinent
    		m_Carnivore = Carnivore
    		m_Weight = Weight
    	End Sub
    
    	' A couple of properties go here
    
    	Public ReadOnly Property Match() As Predicate(Of Dinosaur)
    		Get
    			Return AddressOf IsMatch
    		End Get
    	End Property
    
    	Private Function IsMatch(dino As Dinosaur) As Boolean
    		Return dino.m_Carnivore = m_Carnivore AndAlso dino.m_HomeContinent = m_HomeContinent AndAlso dino.m_Weight <= m_Weight
    	End Function
    End Class

    • Marqué comme réponse Aurel Bera lundi 21 janvier 2013 09:51
    dimanche 20 janvier 2013 09:45
  • Bonjour,

    Pourriez vous vous dire si vous rencontrer d'autre problème afin de faire la validation de votre réponse.

    A bientot


    Cordialement,

    dimanche 20 janvier 2013 16:21
    Auteur de réponse
  • C'est OK merci
    dimanche 20 janvier 2013 18:41
  • Bonjour

    J’ai changé le type de votre thread en Question et j’ai marqué la réponse.

    Merci pour tenir la communauté informée sur la suite de vos démarches.

    Cordialement,


    Aurel BERA, Microsoft
    Microsoft propose ce service gratuitement, dans le but d'aider les utilisateurs et d'élargir les connaissances générales liées aux produits et technologies Microsoft. Ce contenu est fourni "tel quel" et il n'implique aucune responsabilité de la part de Microsoft.

    lundi 21 janvier 2013 09:52