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; = 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(
            return false;
        if (Double.doubleToLongBits(bidVol) != Double.doubleToLongBits(other.bidVol))
            return false;
        return true;

Open in new window


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

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros