三种方法输出D:\C#程序设计\实验3\MyFile.TXT中的MyFile.TXT
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
string strFilename = @"D:\C#程序设计\实验3\MyFile.TXT";
int n = strFilename.IndexOf("MyFile.TXT");
for (int i = n ; i < n + 10; i++)
{
Console.Write(strFilename[i]);
}
Console.ReadKey();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
string strFilename = @"D:\C#程序设计\实验3\MyFile.TXT";
int n = strFilename.LastIndexOf("MyFile.TXT");
for (int i = n; i <n + 10; i++)
{
Console.Write(strFilename[i]);
}
Console.ReadKey();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
string strFilename = @"D:\C#程序设计\实验3\MyFile.TXT";
string ch = strFilename.Substring(14, 10);
Console.WriteLine(ch);
Console.ReadKey();
}
}
}