小编mwi*_*ski的帖子

每个部门的最高薪水

我有一张桌子EmpDetails:

DeptID      EmpName   Salary
Engg        Sam       1000
Engg        Smith     2000
HR          Denis     1500
HR          Danny     3000
IT          David     2000
IT          John      3000
Run Code Online (Sandbox Code Playgroud)

我需要进行查询,找出每个部门的最高薪水.

sql t-sql sql-server

22
推荐指数
6
解决办法
22万
查看次数

Unity场景管理和Android - 无法加载场景

我是C#/ Unity的新手(温柔) - 我正在尝试创建自己的脚本,向Inspector添加一个公共变量,这样我就可以让一个脚本适用于多个GameObjects(或者我认为).

脚本非常简单.

它适用于PC,但它不适用于Android.

using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.EventSystems;

public class BtnLoadScene : MonoBehaviour {
    public Object SceneObj;
    private string SceneName;

    public void LoadLevel()
    {
        SceneName = SceneObj.name;
        Debug.Log (SceneName);
        SceneManager.LoadScene(SceneName);
    }
}
Run Code Online (Sandbox Code Playgroud)

我将此脚本作为组件附加到驱动场景加载的所有按钮(在整个应用程序中).同样,这里的值是我可以将我的"场景"从assets文件夹拖到检查器/组件中(因此我不必显式管理"整数"或"字符串" - 它将全部通过对象引用).

参见例如: 在此输入图像描述

再次,这适用于PC UPDATE:根据评论中的建议,我在独立播放器中尝试了这个并且它失败了.这仅适用于Unity编辑器.当我为Android构建时(是的它编译并且我可以安装APK)它不起作用 - 第一个场景加载,按钮响应我的触摸,我看到它"压下",但亚行抛出:

12-23 15:37:27.028 14816 14847 I Unity   : NullReferenceException: Object reference not set to an instance of an object
12-23 15:37:27.028 14816 14847 I Unity   :   at BtnLoadScene.LoadLevel () [0x00000] in <filename unknown>:0
12-23 15:37:27.028 14816 …
Run Code Online (Sandbox Code Playgroud)

c# unity-game-engine unity5

6
推荐指数
1
解决办法
2764
查看次数

为什么Convert.ToDateTime()在这个例子中不起作用?

我正在尝试使用System.DateTime.Now.ToString()和Convert.ToDateTime,并遇到了一些奇怪的行为.我已将问题缩小到Convert.ToDateTime.由于某种原因,使用System.DateTime.Now设置的DateTime类型与从字符串转换的DateTime类型不同.但是,当您输出其中任何一个时,它们看起来是相同的.

(我尝试使用Trim(),TrimStart()和TrimEnd()无济于事.)

在统一运行之后,这是控制台中的输出:http: //imgur.com/1ZIdPH4

using UnityEngine;
using System;

public class DateTimeTest : MonoBehaviour {
    void Start () {
        //Save current time as a DateTime type
        DateTime saveTime = System.DateTime.Now;
        //Save above DateTime as a string
        string store = saveTime.ToString();
        //Convert it back to a DateTime type
        DateTime convertedTime = Convert.ToDateTime(store);

        //Output both DateTimes
        Debug.Log(saveTime + "\n" + convertedTime);

        //Output whether or not they match.
        if (saveTime == convertedTime)
            Debug.Log("Match: Yes");
        else
            Debug.Log("Match: No");

        //Output both DateTimes converted to …
Run Code Online (Sandbox Code Playgroud)

c# datetime unity-game-engine

4
推荐指数
1
解决办法
889
查看次数

基类实现接口

  1. 基类实现接口的缺点/风险是什么?
  2. 总是在子类上实现接口更好吗?
  3. 你什么时候使用其中一个?

    public interface IFriendly
    {
        string GetFriendly();
    }
    
    
    public abstract class Person: IFriendly
    {
        public abstract string GetFriendly(); 
    }
    
    Run Code Online (Sandbox Code Playgroud)

    VS.

    public interface IFriendly
    {
        string GetFriendly();
    }
    
    public abstract class Person
    {
       // some other stuff i would like subclasses to have
    }
    
    public abstract class Employee : Person, IFriendly
    {
        public string GetFriendly()
        {
            return "friendly";
        }
    }
    
    Run Code Online (Sandbox Code Playgroud)

.net c# oop

4
推荐指数
1
解决办法
4719
查看次数

在C#中使用BinaryReader解析MNIST数据集我做错了什么?

:我是从分析数据集MNIST在C#http://yann.lecun.com/exdb/mnist/

我正在尝试Int32从二进制文件中读取第一个:

FileStream fileS = new FileStream(fileName, FileMode.Open, FileAccess.Read);
BinaryReader reader = new BinaryReader(fileS);
int magicNumber = reader.ReadInt32();
Run Code Online (Sandbox Code Playgroud)

但是,它给了我一个无意义的数字:50855936.

如果我使用 File.ReadAllBytes()

buffer = File.ReadAllBytes(fileName);
Run Code Online (Sandbox Code Playgroud)

然后查看字节,它工作正常(前四个字节现在代表2049),我做了什么错误的BinaryReader?

文件格式如下(我正在尝试读取第一个幻数):

All the integers in the files are stored in the MSB first (high endian) format used by most non-Intel processors. Users of Intel processors and other low-endian machines must flip the bytes of the header.
Run Code Online (Sandbox Code Playgroud)

TRAINING SET LABEL FILE(train-labels-idx1-ubyte):

[offset] [type]          [value]          [description] 
0000     32 bit integer  0x00000801(2049) magic number (MSB …
Run Code Online (Sandbox Code Playgroud)

c# binary endianness mnist

3
推荐指数
1
解决办法
1478
查看次数

Unity C# - 在一个点周围随机生成GameObject

我不知道如何处理这个问题或者是否有任何内置的Unity函数可以帮助解决这个问题所以任何建议都值得赞赏.

这是一张图片,有助于描述我想要做的事情: 在此输入图像描述

我想在设定半径范围内围绕给定点生成游戏对象.但是,它们在此半径中的位置应随机选择.该位置应与原点(在地面上)具有相同的Y轴.下一个主要问题是每个对象不应该与另一个游戏对象发生冲突和重叠,也不应该进入他们的个人空间(橙色圆圈).

到目前为止我的代码不是很好:

public class Spawner : MonoBehaviour {

    public int spawnRadius = 30; // not sure how large this is yet..
    public int agentRadius = 5; // agent's personal space
    public GameObject agent; // added in Unity GUI

    Vector3 originPoint;    

    void CreateGroup() {
        GameObject spawner = GetRandomSpawnPoint ();        
        originPoint = spawner.gameObject.transform.position;        

        for (int i = 0; i < groupSize; i++) {           
            CreateAgent ();
        }
    }

    public void CreateAgent() {
        float directionFacing = Random.Range (0f, 360f);

        // need to …
Run Code Online (Sandbox Code Playgroud)

c# instantiation unity-game-engine gameobject

3
推荐指数
2
解决办法
7091
查看次数

C#和Unity 3D:当用户移动鼠标时,如何使相机在对象周围移动

我正在尝试在Unity 4中进行3D观看模拟,用户可以选择一个对象并移动鼠标使其绕其旋转(360度)。帮助将不胜感激,如果它是用C#编写的,那就太好了!(但这不是必须的)在此先感谢!

c# mouse camera object unity-game-engine

1
推荐指数
1
解决办法
1万
查看次数