get

Shorthand Accessors and Mutators

梦想的初衷 提交于 2019-11-30 08:40:26
I am learning C#, and am learning about making fields private to the class, and using Getters and Setters to expose Methods instead of field values. Are the get; set; in Method 1 and Method 2 equivalent? e.g. is one a shorthand of the other? class Student { // Instance fields private string name; private int mark; // Method 1 public string Name { get; set; } // Method 2 public int Mark { get { return mark; } set { mark = value; } } } Finally, would Method 2 be used when you want to for example perform a calculation before getting or setting a value? e.g. converting value to a percentage or

How to get current seed from C++ rand()?

99封情书 提交于 2019-11-30 08:25:24
I generate a few thousand object in my program based on the C++ rand() function. Keeping them in the memory would be exhaustive. Is there a way to copy the CURRENT seed of rand() at any given time? This would give me the opportunity to store ONLY the current seeds and not full objects. (thus I could regenerate those objects, by regenerating the exact same sub-sequences of random numbers) An exhaustive solution is storing the full sequence of random numbers given by rand() - doesn't worth it. Another would be solution is to implement my own class for randomized numbers. Google gave me no

Mixing GET with POST - is it a bad practice?

一笑奈何 提交于 2019-11-30 07:57:16
Is it a bad practice to mix GET and POST? (note this is in PHP) e.g. <form action="delete.php?l=en&r=homepage" method="post"> <!-- post fields here --> </form> Actually, this will send a POST request request to the server, so technically you aren't mixing the two together : you are using POST with url parameters. There is nothing fundamentally wrong with this, as long as you don't use your URL for parameters that should be in the form as hidden field. There are simple rules : you use GET (possibly with URL parameters) for constant things that do not change the server, and POST for thing that

How to keep already-set GET parameter values on form submission?

故事扮演 提交于 2019-11-30 07:47:59
问题 I have a URL : foo.php?name=adam&lName=scott , and in foo.php I have a form which gives me values of rectangleLength & rectangleBreadth with a submit button. When I click this submit button with form action as $_SERVER['REQUEST_URI'] , I get this result URL: foo.php?rectangleLength=10&rectangleBreadth=5 (these values have been filled in by the user). Notice that I am losing my previous values name & lName from the URL. How can I keep them? Also, keep in mind that I have to come back to foo

C++ Get Total File Line Number

痞子三分冷 提交于 2019-11-30 07:34:56
问题 Is there a function I can use to get total file line number in C++ , or does it have to be manually done by for loop? #include <iostream> #include <ifstream> ifstream aFile ("text.txt"); if (aFile.good()) { //how do i get total file line number? } text.txt line1 line2 line3 回答1: There is no such function. Counting can be done by reading whole lines std::ifstream f("text.txt"); std::string line; long i; for (i = 0; std::getline(f, line); ++i) ; A note about scope, variable i must be outside

Hibernate 中 load方法与get方法以及Query查询与Criteria查询

醉酒当歌 提交于 2019-11-30 07:22:45
本来之前学过Hibernate的,但是近期接到一个项目,为了方便开发,还有考虑到对Hibernate的不足,重新花了4天由浅入深学了下。 在此,Hibernate里面涉及到多种查询的方法,但是每个方法特性并不一样,常用的就基本有四种,当然,或许本人还学的不过广,但是经过各种百度谷歌,主要出现就是这四种,load,get,Query,Criteria。 首先说下load与get的区别: load方法获得的是对应参数的类的代理对象,看清楚,是代理对象,而get方法是对应参数的类的对象。这两种有神马区别,load方法获得的代理对象,如果你没有对其调用里面的方法等等,Hibernate是不会发出SQL语句去查询数据库里面的内容,但是get方法一使用,Hibernate立马就发出SQL语句去查询数据库里面的内容。这意味着,会出现,当数据库中没有对应Id的数据存在时,get方法是返回null值,这很好,对我们的程序影响并不大,可是load的话,因为一开始是获得代理对象,所以并非null值,这样你不能知道到底数据库有没有该数据存在,只有当你使用该代理对象的时候,Hibernate才发出SQL语句,这时当数据库没有该数据,那么系统就会报ObjectNotFoundException异常。还有,当你调用完了相应的方法时关闭了Session,那么get方法没有影响,而load方法会出现异常。

Ajax GET requests to an ASP.NET Page Method?

▼魔方 西西 提交于 2019-11-30 06:59:39
问题 A situation I ran across this week: we have a jQuery Ajax call that goes back to the server to get data $.ajax( { type: "POST", contentType: "application/json; charset=utf-8", url: fullMethodPath, data: data, dataType: "json", success: function(response) { successCallback(response); }, error: errorCallback, complete: completeCallback }); fullMethodPath is a link to a static method on a page (let's say /MyPage.aspx/MyMethod ). public partial class MyPage : Page { // snip [WebMethod] public

NodeJS w/Express Error: Cannot GET /

余生颓废 提交于 2019-11-30 06:02:31
This is what i have, the filename "default.htm" actually exists and loads when doing a readFile with NodeJS. var express = require('express'); var app = express(); app.use(express.static(__dirname + '/default.htm')); app.listen(process.env.PORT); The Error (in browser): Cannot GET / Sdedelbrock You typically want to render templates like this: app.get('/', function(req, res){ res.render('index.ejs'); }); However you can also deliver static content - to do so use: app.use(express.static(__dirname + '/public')); Now everything in the /public directory of your project will be delivered as static

How to create HTTP GET request Scapy?

半腔热情 提交于 2019-11-30 06:01:24
问题 I need to create HTTP GET request and save the data response. I tried to use this: syn = IP(dst=URL) / TCP(dport=80, flags='S') syn_ack = sr1(syn) getStr = 'GET / HTTP/1.1\r\nHost: www.google.com\r\n\r\n' request = IP(dst='www.google.com') / TCP(dport=80, sport=syn_ack[TCP].dport, seq=syn_ack[TCP].ack, ack=syn_ack[TCP].seq + 1, flags='A') / getStr reply = sr1(request) print reply.show() But when I print reply I don't see any data response. In addition, when I checked in 'Wireshark' I got SYN,

PHP Require and Include GET

半世苍凉 提交于 2019-11-30 05:40:52
问题 I would like to require a file but also pass GET variables through the url, but when I write: <?php require_once("myfile.php?name=savagewood"); ?> I get a fatal error. How would I accomplish this functionality in a different way, such that I don't get a fatal error? 回答1: variables will be available as normal you do not have to pass like this. $name='savagewood'; require_once("myfile.php"); $name will be available in myfile.php 回答2: <?php $getVarsArray = $_GET; $postVarsArray = $_POST; /* n