Прямо с PHP-документов: PHP 5.3 В двоичных файлах Windows используется статическая версия библиотеки MCrypt, не требуется DLL.
http://php.net/manual/en/mcrypt .requirements.php
Но если вы действительно хотите его загрузить, просто зайдите на страницу исходного файла mcrypt
http://sourceforge.net/projects / Mcrypt / файлы /? источник = Navbar
Кортежи доступны начиная с.NET4.0 и поддерживают дженерики:
Tuple<string, int> t = new Tuple<string, int>("Hello", 4);
<час> В предыдущих версиях можно использовать System.Collections.Generic.KeyValuePair<K, V>
или решение как следующее:
public class Pair<T, U> {
public Pair() {
}
public Pair(T first, U second) {
this.First = first;
this.Second = second;
}
public T First { get; set; }
public U Second { get; set; }
};
И использование это как это:
Pair<String, int> pair = new Pair<String, int>("test", 2);
Console.WriteLine(pair.First);
Console.WriteLine(pair.Second);
Это производит:
test
2
Или даже это объединило пар в цепочку:
Pair<Pair<String, int>, bool> pair = new Pair<Pair<String, int>, bool>();
pair.First = new Pair<String, int>();
pair.First.First = "test";
pair.First.Second = 12;
pair.Second = true;
Console.WriteLine(pair.First.First);
Console.WriteLine(pair.First.Second);
Console.WriteLine(pair.Second);
, Что выводы:
test
12
true
Я создал реализацию C# Кортежей, которая решает проблему в общем для между двумя и пятью значениями - , вот сообщение в блоге , который содержит ссылку на источник.
Я задавал тот же вопрос сейчас после того, как быстрый google I нашел, что существует парный класс в.NET кроме в Системе. Сеть. UI ^ ~ ^ ( http://msdn.microsoft.com/en-us/library/system.web.ui.pair.aspx ) кто его знает, почему они помещают его там вместо платформы наборов
Если это о словарях и т.п., Вы ищете Систему. Наборы. Универсальный. KeyValuePair< TKey, TValue>.
К сожалению, нет ни одного. Можно использовать System.Collections.Generic.KeyValuePair<K, V>
во многих ситуациях.
, С другой стороны, можно использовать анонимные типы для обработки кортежей, по крайней мере, локально:
var x = new { First = "x", Second = 42 };
последняя альтернатива должна создать собственный класс.
В зависимости от того, что Вы хотите выполнить, Вы могли бы хотеть испытать KeyValuePair.
то, что Вы не можете изменить ключ записи, может, конечно, быть исправлено путем простой замены всей записи новым экземпляром KeyValuePair.
System.Web.UI
contained the Pair
class because it was used heavily in ASP.NET 1.1 as an internal ViewState structure.
Update Aug 2017: C# 7.0 / .NET Framework 4.7 provides a syntax to declare a Tuple with named items using the System.ValueTuple
struct.
//explicit Item typing
(string Message, int SomeNumber) t = ("Hello", 4);
//or using implicit typing
var t = (Message:"Hello", SomeNumber:4);
Console.WriteLine("{0} {1}", t.Message, t.SomeNumber);
see MSDN for more syntax examples.
Update Jun 2012: Tuples
have been a part of .NET since version 4.0.
Here is an earlier article describing inclusion in.NET4.0 and support for generics:
Tuple<string, int> t = new Tuple<string, int>("Hello", 4);
Для того, чтобы все вышеперечисленное работало (мне нужна была пара в качестве ключа словаря). Мне пришлось добавить:
public override Boolean Equals(Object o)
{
Pair<T, U> that = o as Pair<T, U>;
if (that == null)
return false;
else
return this.First.Equals(that.First) && this.Second.Equals(that.Second);
}
, и как только я это сделал, я также добавил
public override Int32 GetHashCode()
{
return First.GetHashCode() ^ Second.GetHashCode();
}
, чтобы подавить предупреждение компилятора.
Библиотека PowerCollections (ранее доступная в Wintellect, но теперь размещенная на Codeplex @ http://powercollections.codeplex.com ) имеет общую структуру Pair.
Некоторые ответы кажутся просто неправильными,
Вот мой класс пар
public class Pair<X, Y>
{
private X _x;
private Y _y;
public Pair(X first, Y second)
{
_x = first;
_y = second;
}
public X first { get { return _x; } }
public Y second { get { return _y; } }
public override bool Equals(object obj)
{
if (obj == null)
return false;
if (obj == this)
return true;
Pair<X, Y> other = obj as Pair<X, Y>;
if (other == null)
return false;
return
(((first == null) && (other.first == null))
|| ((first != null) && first.Equals(other.first)))
&&
(((second == null) && (other.second == null))
|| ((second != null) && second.Equals(other.second)));
}
public override int GetHashCode()
{
int hashcode = 0;
if (first != null)
hashcode += first.GetHashCode();
if (second != null)
hashcode += second.GetHashCode();
return hashcode;
}
}
Вот код теста:
[TestClass]
public class PairTest
{
[TestMethod]
public void pairTest()
{
string s = "abc";
Pair<int, string> foo = new Pair<int, string>(10, s);
Pair<int, string> bar = new Pair<int, string>(10, s);
Pair<int, string> qux = new Pair<int, string>(20, s);
Pair<int, int> aaa = new Pair<int, int>(10, 20);
Assert.IsTrue(10 == foo.first);
Assert.AreEqual(s, foo.second);
Assert.AreEqual(foo, bar);
Assert.IsTrue(foo.GetHashCode() == bar.GetHashCode());
Assert.IsFalse(foo.Equals(qux));
Assert.IsFalse(foo.Equals(null));
Assert.IsFalse(foo.Equals(aaa));
Pair<string, string> s1 = new Pair<string, string>("a", "b");
Pair<string, string> s2 = new Pair<string, string>(null, "b");
Pair<string, string> s3 = new Pair<string, string>("a", null);
Pair<string, string> s4 = new Pair<string, string>(null, null);
Assert.IsFalse(s1.Equals(s2));
Assert.IsFalse(s1.Equals(s3));
Assert.IsFalse(s1.Equals(s4));
Assert.IsFalse(s2.Equals(s1));
Assert.IsFalse(s3.Equals(s1));
Assert.IsFalse(s2.Equals(s3));
Assert.IsFalse(s4.Equals(s1));
Assert.IsFalse(s1.Equals(s4));
}
}