This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$userAgent = $_SERVER['HTTP_USER_AGENT']; | |
if (strpos($userAgent, 'Instagram')) { | |
header('Content-type: application/pdf'); | |
header('Content-Disposition: inline; filename= blablabla'); | |
header('Content-Transfer-Encoding: binary'); | |
header('Accept-Ranges: bytes'); | |
@readfile($file); | |
} | |
else{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace DotNet.Controller | |
{ | |
public class DummyBytesController : ApiController | |
{ | |
[HttpGet] | |
public HttpResponseMessage Get() | |
{ | |
HttpResponseMessage Response; | |
string UserAgent = HttpContext.Current.Request.UserAgent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Student | |
{ | |
public string Name { get; set; } | |
public int Number { get; set; } | |
public int SerialNo { get; set; } | |
public int Grade { get; set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public override bool Equals(object obj) | |
{ | |
if (obj is Student student) | |
{ | |
if (student.SerialNo == SerialNo) | |
return true; | |
else | |
return false; | |
} | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Student student1 = new Student() | |
{ | |
Name = "Joe", | |
Grade = 3, | |
Number = 10, | |
SerialNo = 3213214 | |
}; | |
Student student2 = new Student() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool result = false; | |
if (student1.GetHashCode() == student2.GetHashCode()) | |
result = student1.Equals(student2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hashtable hashtable = new Hashtable(); | |
hashtable.Add("MyFirstKey", 1); | |
hashtable.Add("MySecondKey", true); | |
if(hashtable.Contains("MySecondKey")) //it call Equals | |
Console.WriteLine("I found it"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Student : IEquatable<Student> | |
{ | |
public string Name { get; set; } | |
public int Number { get; set; } | |
public int SerialNo { get; set; } | |
public int Grade { get; set; } | |
public bool Equals(Student other) | |
{ | |
if (other.SerialNo == SerialNo) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Student : IEquatable<Student> | |
{ | |
public string Name { get; set; } | |
public int Number { get; set; } | |
public int SerialNo { get; set; } | |
public int Grade { get; set; } | |
public bool Equals(Student other) | |
{ | |
if (other.SerialNo == SerialNo) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<Student> students = new List<Student>(); | |
// Add some students to this List | |
var specificStudent = new Student() { SerialNo = 12, Number = 34, Grade = 3, Name = "Joe" }; | |
bool exist1 = students.Contains(specificStudent, new NumberEqualityComparer()); | |
bool exist2 = students.Contains(specificStudent, new SerialNoEqualityComparer()); |
OlderNewer