版本:Unity 6 (6000.0)
语言英语
  • C#

断言.AreNotEqual

提出更正建议

成功!

感谢您帮助我们提高 Unity 文档的质量。虽然我们无法接受所有提交,但我们会阅读每位用户提出的变更建议,并在适用的情况下进行更新。

关闭

提交失败

由于一些原因,您的变更建议未能提交。请在几分钟后<a>重试</a>。感谢您抽出时间帮助我们提高 Unity 文档的质量。

关闭

取消

声明

public static void AreNotEqual(Object expected, Object actual, string message);

声明

public static void AreNotEqual(sbyte expected, sbyte actual);

声明

public static void AreNotEqual(sbyte expected, sbyte actual, string message);

声明

public static void AreNotEqual(byte expected, byte actual);

声明

public static void AreNotEqual(byte expected, byte actual, string message);

声明

public static void AreNotEqual(char expected, char actual);

声明

public static void AreNotEqual(char expected, char actual, string message);

声明

public static void AreNotEqual(short expected, short actual);

声明

public static void AreNotEqual(short expected, short actual, string message);

声明

public static void AreNotEqual(ushort expected, ushort actual);

声明

public static void AreNotEqual(ushort expected, ushort actual, string message);

声明

public static void AreNotEqual(int expected, int actual);

声明

public static void AreNotEqual(int expected, int actual, string message);

声明

public static void AreNotEqual(uint expected, uint actual);

声明

public static void AreNotEqual(uint expected, uint actual, string message);

声明

public static void AreNotEqual(long expected, long actual);

声明

public static void AreNotEqual(long expected, long actual, string message);

声明

public static void AreNotEqual(ulong expected, ulong actual);

声明

public static void AreNotEqual(ulong expected, ulong actual, string message);

声明

public static void AreNotEqual(T expected, T actual);

声明

public static void AreNotEqual(T expected, T actual, string message);

声明

public static void AreNotEqual(T expected, T actual, string message, IEqualityComparer<T> comparer);

参数

expected 设想的 Assert 值。
actual 确切的 Assert 值。
message 用来描述 Assert 的字符串。
comparer 用于比较 expectedactual 参数是否拥有相同值的方法。

说明

断言这些值不相等。

expectedactual 相等时显示消息。

using UnityEngine;
using UnityEngine.Assertions;

public class AssertionExampleClass : MonoBehaviour { void Update() { // Make sure the Game Object's layer is never set to 0 Assert.AreNotEqual(0, gameObject.layer); } }

另一个示例

using UnityEngine;
using UnityEngine.Assertions;

// Assert.AreEqual and Assert.AreNotEqual example // // Compare 32 to 32. AreNotEqual prints message. // Compare 32 to 33. AreEqual prints message.

public class Example : MonoBehaviour { void Start() { int expectedInt = 32; int actualInt = 32;

// Do not show message (32 is equal to 32). Assert.AreEqual(expectedInt, actualInt, "AreEqual: " + expectedInt + " equals " + actualInt);

// Show message (32 is equal to 32). Assert.AreNotEqual(expectedInt, actualInt, "AreNotEqual: " + expectedInt + " not equal to " + actualInt);

actualInt = 33;

// Show message (32 is not equal to 33). Assert.AreEqual(expectedInt, actualInt, "AreEqual: " + expectedInt + " equals " + actualInt);

// Do not show message (32 is not equal to 33). Assert.AreNotEqual(expectedInt, actualInt, "AreNotEqual: " + expectedInt + " not equal to " + actualInt); } }