我有3个阵列。 我必须检查这些阵列是否长度相同。 是否有cl和冰 比较?
What is the use of default keyword in C#? Is it introduced in C# 3.0 ?
我有3个阵列。 我必须检查这些阵列是否长度相同。 是否有cl和冰 比较?
为什么
if (array1.Length == array2.Length && array1.Length == array3.Length)
{
}
如果有<代码>。 注
var a1 = new int[] { 1, 2, 3 };
var a2 = new int[] { 1, 2, 3 };
var a3 = new int[] { 1, 2, 3 };
var arr = new[] { a1, a2, a3 }; // group them all in one array
// check if all arrays have the same length as the first
var test = arr.All(x => x.Length == a1.Length);
bool EqualLengths = Arr1.Length == Arr2.Length && Arr2.Length == Arr3.Length;
Doubt that counts as clever and nice though, but don t think there s anything better!
object[] a, b, c;
return (a.Length == b.Length && b.Length == c.Length);
超过if(array1.Length = 阵列2.Length &&阵列1.Length = 阵列3.Length)
?
bool success = false;
var arr1 = new[] { "1", "2", "3" };
var arr2 = new[] { "1", "2", "3" };
var arr3 = new[] { "1", "2", "3" };
if (arr1.Length == arr2.Length)
{
if (arr2.Length == arr3.Length)
{
success = true;
}
}
简单
if (array.Length == array1.Length && array1.Length== array2.Length)
{
// do something
}
// compares all arrays passed in for equal length.
// requires at least two arrays so that comparison can be made,
// otherwise this operation would not matter
bool AreEqualLength(Array a1, Array a2, params Array[] arrs) {
if (a1.Length != a2.Length) return false;
foreach(var arr in arrs)
if (arr.Length != a1.Length)
return false;
return true;
}
int[] a1, a2, a3;
a1 = new int[3];
a2 = new int[1];
a3 = new int[1];
bool equalLength = (a1.Length == (a2.Length & a3.Length));
What is the use of default keyword in C#? Is it introduced in C# 3.0 ?
I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...
I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...
I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...
I have two EF entities. One has a property called HouseNumber. The other has two properties, one called StartHouseNumber and one called EndHouseNumber. I want to create a many to many association ...
How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...
Since I cannot order my dictionary, what is the best way of going about taking key value pairs and also maintaing an index?
Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...