如何在没有项目路径的情况下获取http://www.mysite.com/en网站主页网址的主要部分?最终,我想将Model.Url附加到
这个:
Sitecore.Links.UrlOptions urlOptions = new Sitecore.Links.UrlOptions();
urlOptions.AlwaysIncludeServerUrl = true;
url = Sitecore.Links.LinkManager.GetItemUrl(Sitecore.Context.Item, urlOptions);
Run Code Online (Sandbox Code Playgroud)
给我" http://www.mysite.com/en/undergraduate/business/new-information-landing-pages/Akron-stories "
Model.Url
Run Code Online (Sandbox Code Playgroud)
给我"/本科/商业/新信息 - 登陆页面/阿克伦故事"
var context = new SitecoreContext();
url = context.GetHomeItem<Base_Page>().URL;
Run Code Online (Sandbox Code Playgroud)
给我 "/"
我正在构建一个 android 应用程序,我需要在其中创建一个简单的字符串项目列表,然后我将为列表中的每个项目添加一个特定的控件。
这是我要创建的列表:
List<String> projects = new List<String>(); // How?
Run Code Online (Sandbox Code Playgroud)
我正在尝试的代码:
String projects = new string[] { "hey","yo","app","xamarin","c","xaml" };
Run Code Online (Sandbox Code Playgroud)
我需要计算项目,像这样:
int amount = projects.Count(); // Can I do this?
Run Code Online (Sandbox Code Playgroud)
然后为列表中的每个项目添加控件
// Add the tiles, one by one
for (int i = 0; i < amount; i++)
{
// Inflate the tile
var tile = LayoutInflater.Inflate (Resource.Layout.Tile, null);
// Set its attributes
tile.FindViewById<TextView> (Resource.Id.projectName).Text = currentProject;
// Add the tile
projectScrollView.AddView (tile);
}
Run Code Online (Sandbox Code Playgroud)
“currentProject”字符串是从 SharedPreferences 中检索到的,只是还没有那么远
我在Microsoft Visual Studio 2010中使用C#进行编程.在我的代码中的某处,我在检查行的值是否为null之后在while循环中使用break关键字.
我确信行值为null但仍然是break命令不起作用.我怎样才能解决这个问题?
while (!myfile.EndOfStream)
{
string line = myfile.ReadLine();
if (line == null) { break; }
else
{ ...}
}
Run Code Online (Sandbox Code Playgroud) switch(code)
{
case 'A':
case 'a':
// to do
default:
// to do
}
Run Code Online (Sandbox Code Playgroud)
有没有办法将两个"案例"陈述合并在一起?