Skip to content

Instantly share code, notes, and snippets.

View scorta's full-sized avatar

Nguyen Dang Duc scorta

View GitHub Profile
string[] arr = ...
List<string> list = new List<string>(arr);
string str = "Hello World1";
str = str.Remove(str.Length - 1);
//str is now "Hello World"
private string CapitalizedString(string input)
{
string[] arr = input.Split(' ');
string result = string.Empty;
foreach (string a in arr)
{
result += a.First().ToString().ToUpper() + a.Substring(1) + " ";
}
return result.Trim();
private int CountChar(string src, char x)
{
int count = 0;
for (int i = 0; i < src.Length; i++)
{
//.ToString().ToUpper(): CaSe sensitive or not
if (x.ToString().ToUpper() == src[i].ToString().ToUpper()) count++;
}
private void SaveImageClicked(object sender, GestureEventArgs e)
{
var webClient = new WebClient();
webClient.OpenReadCompleted += WebClientOpenReadCompleted;
webClient.OpenReadAsync(new Uri(IMAGE_URL, UriKind.Absolute));
}
void WebClientOpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
const string tempJpeg = "TempJPEG";
webBrowser.ScriptErrorsSuppressed = true;
MarketplaceReviewTask marketplaceReviewTask = new MarketplaceReviewTask();
marketplaceReviewTask.Show();
// Put all file names in root directory into array.
string[] array1 = Directory.GetFiles(@"C:\");
// Put all txt files in root directory into array.
string[] array2 = Directory.GetFiles(@"C:\", "*.TXT"); // <-- Case-insensitive
private double CalculateConstraintScale(double rotation, int pixelWidth, int pixelHeight)
{
double PiDiv180 = Math.PI / 180;
// Convert angle to radians for the math lib
double rotationRadians = rotation * PiDiv180;
// Centre is half the width and height
double width = pixelWidth / 2.0;
@scorta
scorta / How to determine screen resolution on Windows Phone 8
Created September 15, 2013 01:17
How to determine screen resolution on Windows Phone 8
The 3 screen resolutions for your reference are:
WVGA - 480x800 or 800x480 (15:9 ratio)
WXGA - 768x1280 or 1280x768 (15:9 ratio)
720p - 720x1280 or 1280x720 (16:9 ratio)
if(App.Current.Host.Content.ScaleFactor == 100)
{
// WVGA
}