我对Java中的final变量声明有以下疑问
如果我在代码中声明以下变量:
private final String CURRENT_USER;
Run Code Online (Sandbox Code Playgroud)
Eclipse向我显示以下错误消息:空白的最终字段CURRENT_USER可能尚未初始化
为什么?根据我的理解,如果我将变量声明为final,我只能初始化一次,但在我看来,只有在我声明它而不是在代码中的某个地方之后才能初始化它...
为什么?
TNX
安德里亚
我正在尝试将CSS样式添加到我正在开发的WordPress主题中,如本教程所示:http://www.wpbeginner.com/wp-tutorials/how-to-properly-add-javascripts-and-styles -in-wordpress /但似乎不起作用,我不能理解为什么.
所以这是我个人主题的head.php文件:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
<title><?php bloginfo('name'); ?> <?php if ( is_single() ) { ?> » Blog Archive <?php } ?> <?php wp_title(); ?></title>
<meta name="generator" content="WordPress <?php bloginfo('version'); ?>" /> <!-- leave this for stats -->
<!--
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
<link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); …Run Code Online (Sandbox Code Playgroud) css php wordpress wordpress-theming content-management-system
我是C#的新手(我来自Java),我有以下疑问.
在我工作的应用程序中,我在代码中找到了类似的东西:
if (!String.IsNullOrEmpty(u.nome))
Run Code Online (Sandbox Code Playgroud)
此代码只是检查u对象的nome字段是否不是空的\null字符串.
好的,这对我来说非常清楚,但如果字段不是字符串但是正常的int,我该怎么做才能检查它?
我是C#的新手(我来自Java),我有以下疑问.
在一个类中,我有这个方法的声明:
public List<DataModel.MaliciousCode.MaliciousSmall> getList(DataModel.MaliciousCode.MaliciousSmall model, out int totalRecords)
{
.............................................
.............................................
.............................................
}
Run Code Online (Sandbox Code Playgroud)
我的疑问与参数列表中的out关键字有关.
阅读官方文档我明白这个参数是通过引用传递的(并且它可能没有被初始化).
究竟是什么意思呢?这意味着在C#中我有指针?
我有以下问题在C#中执行查询
我有以下方法执行简单查询:
public List<DataModel.Vulnerability.VulnerabilitySolution> getVulnerabilitySolutionsList(int vulnId)
{
List<DataModel.Vulnerability.VulnerabilitySolution> result = new List<Vulnerability.VulnerabilitySolution>();
System.Data.Common.DbCommand command;
command = _connection.CreateCommand();
command.Connection = this._connection;
_strSQL = "VS.* FROM VulnerabilityAlertDocument_VulnerabilitySolution VAD_VS"
+ " INNER JOIN VulnerabilitySolution VS ON VAD_VS.VulnerabilitySolutionId = VS.Id"
+ " WHERE VAD_VS.VulnerabilityAlertDocumentId = @VULNID ";
addParameter(command, "@VULNID", vulnId);
command.CommandText = _strSQL;
_dt = fillDataTable(command);
DataModel.Vulnerability.VulnerabilitySolution vulnSolution;
foreach (DataRow row in _dt.Rows)
{
vulnSolution = new DataModel.Vulnerability.VulnerabilitySolution(row);
result.Add(vulnSolution);
}
return result;
}
Run Code Online (Sandbox Code Playgroud)
问题是当尝试执行此行时:_dt = fillDataTable(command); 抛出以下异常:'*'附近的语法不正确
可能是什么问题呢?如果我尝试在SQL Server中执行相同的查询(替换参数的值),它可以正常工作
我该如何解决这个问题?
我在处理资源时遇到了一些问题.
我有这个代码:
class ChartHelper
{
//public static System.Drawing.Image GetPdfChart(int percentage)
public static System.Drawing.Bitmap GetPdfChart(int percentage)
{
if (percentage == 0)
{
return null;
}
int WIDTH = 130;
int HEIGHT = 10;
//using (Bitmap bitmap = new Bitmap(WIDTH, HEIGHT))
//{
Bitmap bitmap;
try {
bitmap = new Bitmap(WIDTH, HEIGHT);
using (Graphics graphics = Graphics.FromImage(bitmap))
{
using (LinearGradientBrush brush = new LinearGradientBrush(new Rectangle(0, 0, WIDTH, HEIGHT), Color.LightGreen, Color.Red, LinearGradientMode.Horizontal))
{
graphics.FillRectangle(brush, new Rectangle(0, 0, WIDTH, HEIGHT));
using (Bitmap target = new …Run Code Online (Sandbox Code Playgroud) 我正在使用iTextSharp尝试为我生成的PDF添加页眉和页脚,但是,如果我尝试添加宽度为页面100%的页眉,我会遇到一些问题.
所以我做了以下事情:
1)我创建了一个名为PdfHeaderFooter的类,它扩展了iTextSharp PdfPageEventHelper类
2)进入PdfHeaderFooter我已经实现了生成头的OnStartPage()方法:
// write on start of each page
public override void OnStartPage(PdfWriter writer, Document document)
{
base.OnStartPage(writer, document);
PdfPTable tabHead = new PdfPTable(new float[] { 1F });
PdfPCell cell;
//tabHead.TotalWidth = 300F;
tabHead.WidthPercentage = 100;
cell = new PdfPCell(new Phrase("Header"));
tabHead.AddCell(cell);
tabHead.WriteSelectedRows(0, -1, 150, document.Top, writer.DirectContent);
}
Run Code Online (Sandbox Code Playgroud)
如果我使用像tabHead.TotalWidth = 300F那样的东西; insted的tabHead.WidthPercentage = 100; 它运行良好,但如果我尝试将tabHead.WriteSelectedRows(0,-1,150,document.Top,writer.DirectContent)设置为tabHead表的宽度(就像我在前面的例子中所做的那样)的100%它抛出以下异常的方法:
表格宽度必须大于零.
为什么?问题是什么?如果我将其设置为100%,那么该表的大小是多少?
有人可以帮我解决这个问题吗?
TNX
我是C#.NET的新手,我有以下疑问.
在我正在处理的页面上,我找到了以下链接:
<a class="ui-btn-inline ui-btn ui-icon-delete ui-btn-icon-notext ui-corner-all" href="@Url.Action("Delete", "Groups", new { id = item.gruppoId })">Delete</a>
Run Code Online (Sandbox Code Playgroud)
此链接调用GroupsController类上的Delete()方法.
好的,这是这个方法:
public ActionResult Delete(int id = 0)
{
.......................
.......................
.......................
DO SOME STUFF
.......................
.......................
.......................
return View(model);
}
Run Code Online (Sandbox Code Playgroud)
我的疑问与此方法的签名有关:为什么参数int id = 0?
什么是= 0是什么意思?首先,我认为这是一个简单的初始化,它将it值更改为0,但使用debbugger我发现它不会更改id值.那到底是做什么的?
我有以下问题.
我正在开发一个C#.NET Web应用程序,我正在实现一些包含一些文本区域字段的HTML 5视图.例如,我有这样的事情:
<label for="nome">Description*:</label>
<textarea data-clear-btn="true" name="mitigatingStrategy.Description" id="description" data-mini="true" data-inline="true" required="required" value="@Model.mitigatingStrategy.Description" rows="5" cols="40">Inserire qui la descrizione della nuova Mitigating Strategy</textarea>
Run Code Online (Sandbox Code Playgroud)
它工作正常(**@Model.mitigatingStrategy.Description已正确设置)但Visual Studio签署此行并给我以下验证警告:
验证(HTML5):属性'value'不是元素'textarea'的有效属性
那么问题是什么?如何修复它以获得我的HTML验证?
我对我正在处理的这个自定义主题有疑问:http://www.asper-eritrea.com/
问题是,当您将鼠标移到链接(例如帖子标题)上时,它会将颜色更改为黄色,因此文本看起来不可见。
发生这种情况是因为它使用了这些 CSS 设置(我看到它使用FireBug):
.widget-sidebar ul li a, a:hover {
color: #f1b000;
}
Run Code Online (Sandbox Code Playgroud)
但为什么要使用这些 CSS 设置呢?这不是包含在列表中的链接,该列表本身包含在具有类的元素中widget-sidebar
我该如何解决这个问题?
总氮
c# ×7
.net ×4
asp.net ×2
css ×2
html ×2
asp.net-mvc ×1
final ×1
html5 ×1
itext ×1
itextsharp ×1
java ×1
pdf ×1
php ×1
sql-server ×1
wordpress ×1