日期:2014-05-17  浏览次数:20873 次

C#和java是什么关系?为什么那么像呢?
我初学c#,但发现C#和java 非常非常相像,我对java还比较了解,是不是意味着C#的80%我就不用学了?

------解决方案--------------------
看兴趣。做一个删除,修改,查询再加一个分页 .net bs 1分钟不到搞定
区别就是.net有的功能都分装成控件拉出来用就好了 而java都要手写
当然java也非常好的 不然分方向我也不会不选.net而选java了
什么语言思路都一样
------解决方案--------------------
那是你只知道java、C#,你要是知道其他语言你会发现,都是很相似的,,
相似的只是语法而已,,
------解决方案--------------------
你对java比较了解的话,学起C#来更快,都是面向对象语言。


------解决方案--------------------
你说的是C# 1.0。

C#已经早就和Java不像了。

随便贴一个C#代码:你能看懂80%么?
C# code
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            MazeModel mm = new MazeModel(7, 5);
            mm.DisplayMaze();
        }
    }

    class MazeModel
    {
        private bool[] edges;

        public int HorizontalVertex { get; private set; }

        public int VerticalVertex { get; private set; }

        private bool getEdgeValue(int edgeindex)
        {
            try
            {
                return edges[edgeindex];
            }
            catch
            {
                return false;
            }
        }

        private void setEdgeValue(int edgeindex, bool value)
        {
            try
            {
                edges[edgeindex] = value;
            }
            catch { }
        }

        private int nodeToEdgeIndex(int x, int y, int dir)
        {
            if (x == 0 && dir == 1) return -1;
            if (x % HorizontalVertex == HorizontalVertex - 1 && dir == 2) return -1;
            if (y == 0 && dir == 0) return -1;
            if (y >= HorizontalVertex * (VerticalVertex - 1) && dir == 3) return -1;

            return (y * 2 + ((dir == 1 || dir == 2) ? 0 : (dir == 0 ? -1 : 1))) * HorizontalVertex + x - (dir == 1 ? 1 : 0);
        }

        private int nodeindexToEdgeIndex(int nodeindex, int dir)
        {
            int x;
            int y;
            nodeIndexToNode(nodeindex, out x, out y);
            return nodeToEdgeIndex(x, y, dir);
        }

        private void nodeIndexToNode(int nodeindex, out int x, out int y)
        {
            x = nodeindex % HorizontalVertex;
            y = nodeindex / HorizontalVertex;
        }

        private int nodeToNodeIndex(int x, int y)
        {
            return y * HorizontalVertex + x;
        }

        private void edgeIndexToNodeIndex(int edgeindex, out int node1, out int node2)
        {
            int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
            if (edgeindex / HorizontalVertex % 2 != 0)
            {
                x1 = x2 = edgeindex % HorizontalVertex;
                y1 = edgeindex / (HorizontalVertex * 2);
                y2 = y1 + 1;
            }
            else
            {
                x1 = edgeindex % HorizontalVertex;
                x2 = x1 + 1;
                y1 = y2 = edgeindex / (HorizontalVertex * 2);
            }
            node1 = nodeToNodeIndex(x1, y1);
            node2 = nodeToNodeIndex(x2, y2);
        }

        private int edgeIndexToNodeIndex(int edgeindex, int node)
        {
            int node1, node2;
            edgeIndexToNodeIndex(edgeindex, out node1, out node2);
            return node1 == node ? node2 : node1;
        }

        private IEnumerable<int> getNodeEdges(int nodeIndex, List<int> blocklist)
        {
            return Enumerable
                .Range(0, 4)
                .Select(x => nodeindexToEdgeIndex(nodeIndex, x))
                .Where(x => getEdgeValue(x) && !blocklist.Contains(x));
        }

        private void generateMaze()
        {
            List<int> blockEdges = new List<int>();
            while (blockEdges.