Microsoft was interested, nay "eager" to work with Java. However Microsoft deployed their infamous "embrace and extend" strategy. The basic idea is to add extensions to Java that are outside of the standard, entice people to use these extension, and bit by bit claim Java as their own. They did this in the HTML arena. This led to the situation where web pages would only work with the Microsoft browser (Explorer?).
Sun was not happy with this and kicked off a lawsuit. I suppose the basic premise of the suit was that this thing Microsoft was calling Java did not comply with the specification and hence Microsoft was out of bound in calling it Java. Somewhat surprisingly this pushed Microsoft into generated their own Java look-alike/work-alike that they called C#. Sun filed the lawsuit around 1997. They won the suit around 2002. Microsoft settled the suit in 2001 after a public release of C# in 2000.
As an interesting sidenote, another significant lawsuit in more recent years involving Java has been settled. Oracle purchased Sun, so they now own Java. Oracle loves to sue people, so they sued Google. Google is/was using Java in Android phones. The situation though is the exact inverse of Microsft/Sun. Google is writing their own implementation of the JVM, taking pains to comply with existing Java specification. Microsoft was developing their own dialect of Java that did not adhere to the specification. It is heartening that Google won the lawsuit with Oracle.
People today ask whether C# resembles C++ or Java more closely. And the answer is that it resembles Java. Given the name, you might expect it to be in the C "family", but it really isn't. Of course the Java syntax was closely modeled after C. In some ways Java was intended to be "C++ done right" as far as language features. The whole JVM and "run anywhere" thing were an entirely different aspect of things. Note that they never do compare C# to good old C -- which is not surprising in that C is not an object oriented language whereas C++ and Java both are. They all share a C-like syntax with braces and semicolons.
Strangely though Microsoft never made a serious effort for C# to be a cross platform thing. They are making these noises now (in 2024), but I don't see it getting any real traction. At one point it was the "cool thing" to have Java applets that would run in a browser. We never saw this with C# (and it fizzled in short order for Java as well).
When I read about C# compared to other languages, the language "Delphi" gets mentioned by some people. I don't know the first thing about Delphi, so I am unable to say anything about that.
C# has gone on to add features to develop in unanticipated directions. I am too new to C# to say anything about those sorts of things.
Tom's Computer Info / tom@mmto.org