Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
D

Dave Doknjas

@Dave Doknjas
About
Posts
269
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • from java to c#
    D Dave Doknjas

    I don't have a conversion for some of the Java types you're using, but the following syntax should be correct:

    public static string Dcipher(string encryptedText1)
    {
    	try
    	{
    		sbyte\[\] desKeyData = {(sbyte) 0x01, (sbyte) 0x02, (sbyte) 0x03, (sbyte) 0x04, (sbyte) 0x05, (sbyte) 0x06, (sbyte) 0x07, (sbyte) 0x08};
    		DESKeySpec desKeySpec = new DESKeySpec(desKeyData);
    		SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
    		SecretKey key = null;
    		try
    		{
    			key = keyFactory.generateSecret(desKeySpec);
    		}
    		catch (InvalidKeySpecException ex1)
    		{
    		}
    		sbyte\[\] initVector = new sbyte\[\] {0x10, 0x10, 0x01, 0x04, 0x01, 0x01, 0x01, 0x02};
    
    		AlgorithmParameterSpec algParamSpec = new IvParameterSpec(initVector);
    		Cipher m\_decrypter = Cipher.getInstance("DES/OFB32/NoPadding");
    		m\_decrypter.init(Cipher.DECRYPT\_MODE, key, algParamSpec);
    
    		sbyte\[\] encryptedText = encryptedText1.Bytes;
    		sbyte\[\] decryptedText = m\_decrypter.doFinal(encryptedText);
    		return (new string(decryptedText));
    
    	}
    	catch (BadPaddingException ex)
    	{
    		Console.WriteLine(ex.ToString());
    		Console.Write(ex.StackTrace);
    	}
    	catch (IllegalBlockSizeException ex)
    	{
    		Console.WriteLine(ex.ToString());
    		Console.Write(ex.StackTrace);
    	}
    	catch (InvalidAlgorithmParameterException ex)
    	{
    		Console.WriteLine(ex.ToString());
    		Console.Write(ex.StackTrace);
    	}
    	catch (InvalidKeyException ex)
    	{
    		Console.WriteLine(ex.ToString());
    		Console.Write(ex.StackTrace);
    	}
    	catch (NoSuchPaddingException ex)
    	{
    		Console.WriteLine(ex.ToString());
    		Console.Write(ex.StackTrace);
    	}
    	catch (NoSuchAlgorithmException ex)
    	{
    		Console.WriteLine(ex.ToString());
    		Console.Write(ex.StackTrace);
    	}
    	return "";
    }
    

    Dave Doknjas Convert between VB, C#, C++, & Java www.tangiblesoftwaresolutions.com Instant C# - VB to C# Converter Instant VB - C# to VB Converter

    C# csharp java

  • Java code Convert to C#
    D Dave Doknjas

    It can almost be completely converted to C#:

    using System.Windows.Forms;

    public class ConfirmDeleteDialog
    {
    public static readonly int YES = DialogResult.Yes;
    public static readonly int NO = DialogResult.No;
    public static readonly int CANCEL = DialogResult.Cancel;
    internal static readonly int OK = DialogResult.OK;
    internal static readonly int CLOSED = JOptionPane.CLOSED_OPTION; //no equivalent to 'CLOSED_OPTION'

    public static int showMessage(Component parent, string message, string title)
    {
    	return MessageBox.Show(parent, message, title, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
    }
    

    }

    Dave Doknjas Convert between VB, C#, C++, & Java www.tangiblesoftwaresolutions.com Instant C# - VB to C# Converter Instant VB - C# to VB Converter

    Java csharp java help question

  • Function Accepting Parameters of Any Type
    D Dave Doknjas

    Note that you can also do this with arrays:

    public void MyFunction(T[] myArray){
    }

    Dave Doknjas Convert between VB, C#, C++, & Java www.tangiblesoftwaresolutions.com Instant C# - VB to C# Converter Instant VB - C# to VB Converter

    C# help data-structures

  • Converting from C to C#
    D Dave Doknjas

    All converters will offer a free trial/demo version. Try it out and compare the results with some common sense. Even if the conversion is less than 100%, it may give you something you would have missed. The main challenge of converting C/C++ code to other languages, especially with pointers, is that a C/C++ declaration alone does not tell you how something is used. This is in contrast to C# where the declaration does tell you all you need to know for a translation to other languages.

    David Anton Convert between VB, C#, C++, & Java www.tangiblesoftwaresolutions.com Instant C# - VB to C# Converter Instant VB - C# to VB Converter

    C# csharp asp-net hardware help question

  • VB To C# ( _value = Asc(Mid(LStr, IValue, 1)))
    D Dave Doknjas

    Remember, legacy VB string functions are 1-based, not 0-based, so the equivalent is:

    _value = Convert.ToInt32(LStr[IValue - 1]));

    David Anton Convert between VB, C#, C++, & Java www.tangiblesoftwaresolutions.com Instant C# - VB to C# Converter Instant VB - C# to VB Converter

    C# csharp help

  • Why c# do not support Multiple Inheritance
    D Dave Doknjas

    There's a reason most modern languages don't support multiple inheritance.

    David Anton Convert between VB, C#, C++, & Java www.tangiblesoftwaresolutions.com Instant C# - VB to C# Converter Instant VB - C# to VB Converter

    C# csharp oop

  • Delegate w/ Lambda
    D Dave Doknjas

    internal delegate void SetStatus(string Text);

    private void SetStatusStrip(string Text)
    {
    SetStatus d = new SetStatus(() => {
    // Do some work.
    });
    this.Invoke(d, new object[] {Text});
    }

    David Anton Convert between VB, C#, C++, & Java www.tangiblesoftwaresolutions.com Instant C# - VB to C# Converter Instant VB - C# to VB Converter

    C# csharp question linq functional

  • Another Lambda Expression Problem
    D Dave Doknjas

    You'll need to use the hidden VB event field (add "Event" to the event name):

    Dim local As EventHandler(Of MailPoppedEventArgs) = Me.MailPoppedEvent

    David Anton Convert between VB, C#, C++, & Java www.tangiblesoftwaresolutions.com

    Visual Basic help csharp database linq

  • Structure passing problem
    D Dave Doknjas

    The problem is that for VB6, the default was "ByRef", but for VB.NET, the default is "ByVal".

    David Anton Convert between VB, C#, C++, & Java www.tangiblesoftwaresolutions.com

    Visual Basic help database visual-studio

  • Structure passing problem
    D Dave Doknjas

    If you don't specify "ByRef" or "ByVal", then the parameter is "ByVal" by default. You want:

    Sub db_create_cs(ByRef dbc As db_connection)

    David Anton Convert between VB, C#, C++, & Java www.tangiblesoftwaresolutions.com

    Visual Basic help database visual-studio

  • Problem using a fixed length string in a structure used as a parameter to a Win32API call
    D Dave Doknjas

    The main thing is that the 2nd parameter should be 'ByRef':

    Declare Function midiInGetDevCaps Lib "winmm.dll" Alias "midiInGetDevCapsA" (ByVal uDeviceID As Integer, ByRef lpCaps As MIDIINCAPS, ByVal uSize As Integer) As Integer

    Public Structure MIDIINCAPS
    Dim ManufacturerID As Short
    Dim ProductID As Short
    Dim DriverVersion As Integer
    Dim Label As String
    Dim Support As Integer
    End Structure

    David Anton Convert between VB, C#, C++, & Java www.tangiblesoftwaresolutions.com

    Visual Basic help csharp data-structures regex json

  • Convert C++/CLI code to Visual Studio 2002 Managed C++
    D Dave Doknjas

    Are you sure you want 2002 Managed C++? The pre-CLI managed C++ syntax was a failed experiment - the syntax was available only for a short time and it was quickly superceded by C++/CLI (even C++/CLI is not commonly used).

    David Anton Convert between VB, C#, C++, & Java www.tangiblesoftwaresolutions.com

    Managed C++/CLI csharp c++ visual-studio help question

  • Convert from C# to VC++2010 dataGridView Enter-Key Movements?
    D Dave Doknjas

    public ref class MyDataGrid : DataGridView
    {
    protected:
    virtual bool ProcessDialogKey(Keys ^keyData) override
    {
    Keys ^key = keyData & Keys::KeyCode;
    if (key == Keys::Enter)
    {
    DataGridView::OnKeyDown(gcnew KeyEventArgs(keyData));
    return true;
    }
    else
    {
    return DataGridView::ProcessDialogKey(keyData);
    }
    }
    };

    David Anton Convert between VB, C#, C++, & Java www.tangiblesoftwaresolutions.com

    Managed C++/CLI csharp c++ question

  • Translating the Mod Operator in VB to c++ check
    D Dave Doknjas

    The second one will be something like:

    strTextChar = static_cast(static_cast(strTextChar[0]) ^ intTemp);

    David Anton Convert between VB, C#, C++, & Java www.tangiblesoftwaresolutions.com

    C / C++ / MFC c++

  • if(NULL == MyPointer)
    D Dave Doknjas

    I understand the reason people give for doing this, but as far as I'm concerned if you can remember to reverse these conditions then you can also bloody well remember to get the number of '='s right.

    David Anton Convert between VB, C#, C++, & Java www.tangiblesoftwaresolutions.com

    C / C++ / MFC help question

  • Left$, Right$, Trim$, "$" Advice.
    D Dave Doknjas

    .NET strings can certainly be 'null' ('Nothing' in VB). The point the author was making (checking my own copy of that book), is that the old VB6 functions accepted arguments that may be Nothing, while the ones with $ after it did not. After upgrading to VB.NET, the VB.NET versions of those functions will throw an exception if you pass Nothing to them. For this reason, he suggests to try to isolate the issues before upgrading. Either way, you'll have to go through this, but the more issues you can resolve before upgrading, the less overwhelming the upgrade will be. I did a number of upgrades for clients a few years ago and I can tell you that this is true (and the book you're using is excellent).

    David Anton Convert between VB, C#, C++, & Java www.tangiblesoftwaresolutions.com

    Visual Basic question csharp dotnet algorithms

  • Timer() - anything faster?
    D Dave Doknjas

    Try System.Diagnostics.Stopwatch

    David Anton Convert between VB, C#, C++, & Java www.tangiblesoftwaresolutions.com

    Managed C++/CLI performance question

  • On Error Resume Next
    D Dave Doknjas

    If you can narrow down the affected code to a line or two, then the following VB code:

    On Error Resume Next
    Foo()

    can be converted to:

    try
    {
    Foo();
    }
    catch
    {
    //ignore exceptions
    }

    For longer code blocks, you'll have to use a separate try/empty catch for each single line of code.

    David Anton Convert between VB, C#, C++, & Java www.tangiblesoftwaresolutions.com

    modified on Tuesday, January 18, 2011 4:42 PM

    C# csharp help question career

  • Delegates in Managed C++
    D Dave Doknjas

    Remove the 'static' keyword - it's the cause of the error (and add a semi-colon after the class closing brace).

    David Anton Convert between VB, C#, C++, & Java www.tangiblesoftwaresolutions.com

    Managed C++/CLI c++ help

  • Problem to Convert a Javascript GTIN calculate function to VB.net
    D Dave Doknjas

    It must be due to 'index' not being declared. Try:

    For index As Integer = gNum To 1 Step -1

    David Anton Convert between VB, C#, C++, & Java www.tangiblesoftwaresolutions.com

    Visual Basic help csharp javascript database
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups