n1ckooo Posted January 5, 2010 at 08:51 PM Report Share #304323 Posted January 5, 2010 at 08:51 PM Class UnpackAllMarkets 'For getAllMArkets Public marketData As MarketDataType() = {} 'The returned array of market data Private Const BaseDate As DateTime = #1/1/1970# Private Const ColonCode = "&%^@" 'The substitute code for "\:" Sub New(ByVal MarketString As String) Dim n As Integer, Mdata, Field As String() Mdata = MarketString.Replace("\:", ColonCode).Split(":") 'Get array of Market substrings n = UBound(Mdata) - 1 ReDim marketData(n) For i = 0 To n Field = Mdata(i + 1).Replace("\~", "-").Split("~") 'Get array of data fields marketData(i) = New MarketDataType With marketData(i) .marketId = Field(0) 'Load the array items .marketName = Field(1).Replace(ColonCode, ":") .marketType = Field(2) .marketStatus = Field(3) .eventDate = BaseDate.AddMilliseconds(Field(4)) .menuPath = Field(5).Replace(ColonCode, ":") .eventHeirachy = Field(6) .betDelay = Field(7) .exchangeId = Field(8) .countryCode = Field(9) .lastRefresh = BaseDate.AddMilliseconds(Field(10)) .noOfRunners = Field(11) .noOfWinners = Field(12) .totalAmountMatched = Val(Field(13)) .bspMarket = (Field(14) = "Y") .turningInPlay = (Field(15) = "Y") End With Next End Sub End Class Class MarketDataType 'For getAllMarkets data Public marketId As Integer Public marketName As String Public marketType As String Public marketStatus As String Public eventDate As DateTime Public menuPath As String Public eventHeirachy As String Public betDelay As Integer Public exchangeId As Integer Public countryCode As String Public lastRefresh As DateTime Public noOfRunners As Integer Public noOfWinners As Integer Public totalAmountMatched As Double Public bspMarket As Boolean Public turningInPlay As Boolean End Class Private Sub bMarkets_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bMarkets.Click Print("*** Markets ***") Dim oMarketsReq As New BFUK.GetAllMarketsReq Dim oMarketsResp As BFUK.GetAllMarketsResp With oMarketsReq .header = oHeaderUK() ReDim .eventTypeIds(0) : .eventTypeIds(0) = 7 'For horse racing ReDim .countries(1) : .countries(0) = "GBR" : .countries(1) = "ZAF" .fromDate = Today .toDate = Today.AddDays(1) End With oMarketsResp = BetFairUK.getAllMarkets(oMarketsReq) 'Call the UK API With oMarketsResp CheckHeader(.header) Print("ErrorCode = " & .errorCode.ToString) If .errorCode = BFUK.GetAllMarketsErrorEnum.OK Then Dim AllMarkets As New UnpackAllMarkets(.marketData) With AllMarkets For i = 0 To .marketData.Length - 1 With .marketData(i) Print(.marketID & " " & .marketStatus & " " & .marketName & “ “ & .menuPath) End With Next End With End If End With End Sub Alguém me ajuda a converter isto para C#? Link to comment Share on other sites More sharing options...
bruno1234 Posted January 5, 2010 at 09:01 PM Report Share #304334 Posted January 5, 2010 at 09:01 PM A melhor maneira é leres um tutorial de C#, isso não tem código complexo, num instante aprendes a fazer isso. Matraquilhos para Android. Gratuito na Play Store. https://play.google.com/store/apps/details?id=pt.bca.matraquilhos Link to comment Share on other sites More sharing options...
n1ckooo Posted January 5, 2010 at 09:59 PM Author Report Share #304349 Posted January 5, 2010 at 09:59 PM A melhor maneira é leres um tutorial de C#, isso não tem código complexo, num instante aprendes a fazer isso. Eu já tentei muitas coisas, continua sem entender. devo estar a confundir as coisas. :S Link to comment Share on other sites More sharing options...
jpaulino Posted January 5, 2010 at 10:01 PM Report Share #304350 Posted January 5, 2010 at 10:01 PM Tenta aqui: http://www.developerfusion.com/tools/convert/vb-to-csharp/ Link to comment Share on other sites More sharing options...
n1ckooo Posted January 5, 2010 at 10:31 PM Author Report Share #304358 Posted January 5, 2010 at 10:31 PM Tenta aqui: http://www.developerfusion.com/tools/convert/vb-to-csharp/ vou explicar melhor eu sei converter quase tudo, menos a expressao, "reDim" e a outra duvida é a class MarketDataType no c# é na mesma uma classe ou é uma estrutura? Link to comment Share on other sites More sharing options...
jpaulino Posted January 5, 2010 at 10:38 PM Report Share #304360 Posted January 5, 2010 at 10:38 PM Sabes ou o link que te mostrei não conseguiu converter ? 😉 É que se sabes nunca tinhas dito nada. Usa colecções que é muito mais simples de trabalhar. Link to comment Share on other sites More sharing options...
n1ckooo Posted January 5, 2010 at 11:12 PM Author Report Share #304369 Posted January 5, 2010 at 11:12 PM sei, desculpa não ter dito. o link que me deste já conhecia nem fui lá porque sei que não traduz reDim para c#. Vou verificar isso das colecções... se tiver duvidas (vou ter),volto cá.... obrigado Link to comment Share on other sites More sharing options...
ribeiro55 Posted January 6, 2010 at 02:04 AM Report Share #304394 Posted January 6, 2010 at 02:04 AM Se é esse o caso, porque raio não meteste só as partes onde aparecia ReDim ? Nem C# nem VB conseguem fazer isso. O ReDim é um atalho do VB que internamente cria uma nova array com o novo tamanho e copia os dados da original. Basta escrever um algoritmo em C# para tal. Sérgio Ribeiro "Great coders aren't born. They're compiled and released""Expert coders do not need a keyboard. They just throw magnets at the RAM chips" Link to comment Share on other sites More sharing options...
n1ckooo Posted January 6, 2010 at 03:59 PM Author Report Share #304494 Posted January 6, 2010 at 03:59 PM Se é esse o caso, porque raio não meteste só as partes onde aparecia ReDim ? Nem C# nem VB conseguem fazer isso. O ReDim é um atalho do VB que internamente cria uma nova array com o novo tamanho e copia os dados da original. Basta escrever um algoritmo em C# para tal. Voces falam com uma arrogancia um pouco estranha,para uma comunidade... mas era mesmo isso que queria saber... obrigado... Link to comment Share on other sites More sharing options...
ribeiro55 Posted January 6, 2010 at 04:02 PM Report Share #304496 Posted January 6, 2010 at 04:02 PM Arrogância? É uma pergunta legítima: "Porque razão não mencionaste apenas o ReDim, se era tudo quanto precisavas saber?" Já está resolvido, não interessa 😉 Sérgio Ribeiro "Great coders aren't born. They're compiled and released""Expert coders do not need a keyboard. They just throw magnets at the RAM chips" Link to comment Share on other sites More sharing options...
n1ckooo Posted January 6, 2010 at 09:23 PM Author Report Share #304536 Posted January 6, 2010 at 09:23 PM exacto é uma pergunta legitima e respondendo porque também não sabia o que era a class MarketDataType, mas agora não interessa já entendi o código vou adapta-lo ao c# . obrigado pelo tempo despendido, estou a tentar entender as colecções... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now