Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Convert Java to C# Help.

Avatar of Dynotoe
Dynotoe asked on
4 Comments1 Solution613 ViewsLast Modified:
Hi Ladoes and Gents,

I am very new to Java and had a little code I would love some help with.  I basically need to get the associative C# version of this Java code.  Please if you could comment the heck out of the code to describe what it does on the c# versioni as well it would be greatly appreciated.

FYI I have tried to install the java to C# conversion assistant on a few different machines with different versions of visual studio with no luck.  I get an error message so a automated conversion is out.

Let me please relay my gracious thank you in advance.  I hope everyone is well.

Best - Dynotoe
import java.text.SimpleDateFormat;
import java.util.TimeZone;

public class TickData extends Data {
    //number of bytes in binary representation
    public static final int BYTES_COUNT = 8 + 8 * 4; //time + ask + bid + askVol + bidVol
    public double ask;
    public double bid;
    public double askVol;
    public double bidVol;
    public TickData() {

    public TickData(long time, double ask, double bid, double askVol, double bidVol) {
        this.ask = ask;
        this.bid = bid;
        this.askVol = askVol;
        this.bidVol = bidVol;

    public void fromBytes(byte[] bytes, int off) {
        time = getLong(bytes, off);
        ask = getDouble(bytes, off + 1 * 8);
        bid = getDouble(bytes, off + 2 * 8);
        askVol = getDouble(bytes, off + 3 * 8);
        bidVol = getDouble(bytes, off + 4 * 8);
    public final void toBytes(byte[] buff, int off) {
        off = putLong(buff, off, time);
        off = putDouble(buff, off, ask);
        off = putDouble(buff, off, bid);
        off = putDouble(buff, off, askVol);
        putDouble(buff, off, bidVol);

    public int getBytesCount() {
        return BYTES_COUNT;

    public String toString() {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSZ");
        StringBuilder stamp = new StringBuilder();
        stamp.append(time).append("[").append(format.format(time)).append("] / ");
        stamp.append(ask).append(" / ").append(bid);
        return stamp.toString();

    public int hashCode() {
        final int prime = 31;
        int result = super.hashCode();
        long temp;
        temp = Double.doubleToLongBits(ask);
        result = prime * result + (int) (temp ^ (temp >>> 32));
        temp = Double.doubleToLongBits(askVol);
        result = prime * result + (int) (temp ^ (temp >>> 32));
        temp = Double.doubleToLongBits(bid);
        result = prime * result + (int) (temp ^ (temp >>> 32));
        temp = Double.doubleToLongBits(bidVol);
        result = prime * result + (int) (temp ^ (temp >>> 32));
        return result;

    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (!super.equals(obj))
            return false;
        if (getClass() != obj.getClass())
            return false;
        TickData other = (TickData) obj;
        if (Double.doubleToLongBits(ask) != Double.doubleToLongBits(other.ask))
            return false;
        if (Double.doubleToLongBits(askVol) != Double.doubleToLongBits(other.askVol))
            return false;
        if (Double.doubleToLongBits(bid) != Double.doubleToLongBits(other.bid))
            return false;
        if (Double.doubleToLongBits(bidVol) != Double.doubleToLongBits(other.bidVol))
            return false;
        return true;
Avatar of spule
spuleFlag of Czechia image

Our community of experts have been thoroughly vetted for their expertise and industry experience.

This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answers