strong-typing

Are there strongly-typed collections in Objective-C?

放肆的年华 提交于 2019-12-27 11:39:50
问题 I'm new to Mac/iPhone programming and Objective-C. In C# and Java we have "generics", collection classes whose members can only be of the type declared. For example, in C# Dictionary<int, MyCustomObject> can only contain keys that are integers and values that are of type MyCustomObject. Does a similar mechanism exist in Objective-C? 回答1: In Xcode 7, Apple has introduced 'Lightweight Generics' to Objective-C. In Objective-C, they will generate compiler warnings if there is a type mismatch.

Why can't pointer fit variable of different type, even though sizeof is same?

假如想象 提交于 2019-12-25 19:01:28
问题 Why the sizeof any pointer is 4 or 8 bytes, but it cannot fit any different variable? I get error while trying to assign a double pointer an int pointer value. int *int_ptr{nullptr}; float *float_ptr{nullptr}; double *double_ptr{nullptr}; long double *long_double_ptr{nullptr}; string *string_ptr{nullptr}; vector<int> *vector_ptr{nullptr}; cout << "sizeof int pointer is " << sizeof int_ptr; //8 or 4 cout << "sizeof float pointer is " << sizeof float_ptr; //8 or 4 cout << "sizeof double pointer

Why can't pointer fit variable of different type, even though sizeof is same?

守給你的承諾、 提交于 2019-12-25 19:01:20
问题 Why the sizeof any pointer is 4 or 8 bytes, but it cannot fit any different variable? I get error while trying to assign a double pointer an int pointer value. int *int_ptr{nullptr}; float *float_ptr{nullptr}; double *double_ptr{nullptr}; long double *long_double_ptr{nullptr}; string *string_ptr{nullptr}; vector<int> *vector_ptr{nullptr}; cout << "sizeof int pointer is " << sizeof int_ptr; //8 or 4 cout << "sizeof float pointer is " << sizeof float_ptr; //8 or 4 cout << "sizeof double pointer

What does strict types do in PHP?

眉间皱痕 提交于 2019-12-25 01:28:14
问题 I've seen this new line in PHP7 but nobody really explains what it means. I've googled it and all they talk about is will you be enabling it or not like a poll type of thing. declare(strict_types = 1); What does it do? How does it affect my code? Should I do it? Some explanation would be nice. 回答1: From Treehouse blog : With PHP 7 we now have added Scalar types. Specifically: int, float, string, and bool. By adding scalar type hints and enabling strict requirements, it is hoped that more

Strongly-typed view difference (MVC sources vs. assembly)

ε祈祈猫儿з 提交于 2019-12-24 12:24:01
问题 I'm trying to create a strongly typed partial view <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<Pt.Data.Services>>" %> <table> <% foreach (Pt.Data.Services item in Model) { Html.RenderPartial("ServiceItem",item); } %> </table> in the Controller: IEnumerable<Services> Model=null; using (tl ctx = new tl(Config.ConnectionString)) { Model = ctx.Services.ToList(); } return View("List",Model); This workied well when

What Strongly-Typed Data-Structure can I use to hold a collection of multiple RecordSets with different shape

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-24 11:36:48
问题 At the request of a responder to my original question here, I have been asked to reword the question in an effort to get to the bottom of the actual requirement. What Strongly-Typed Data-Structure can I use to hold a collection of multiple RecordSets where each RecordSet will contain rows that may be of a different shape to the other RecordSets ? This need is driven by the need to handle the data coming back from a Stored Procedure via a DbDataReader . The Stored Procedure may have multiple

Why can't I pull a ushort from a System.Object and then cast it as a uint? (C#)

南笙酒味 提交于 2019-12-23 20:32:09
问题 I'm manipulating the items in a list that's a System.Management.ManagementObjectCollection . Each of these items is a System.Management.ManagementObject which contains properties indexed by string. See: foreach (ManagementObject queryObj in searcher.Get()) { string osversion = (string)queryObj["Version"]; string os = (string)queryObj["Name"]; uint spmajor = (uint)queryObj["ServicePackMajorVersion"]; uint spminor = (uint)queryObj["ServicePackMinorVersion"]; ... ... ... } Each "dictionary

ASP.NET MVC Two Way Data Binding of Model to Radio Button List using Typed Model

房东的猫 提交于 2019-12-21 15:39:07
问题 I have a mvc view made up of a matrix of radio buttons. Each row of radio buttons is in a group and represents a typed object from the model. Using the guidance of various blogs and postings I have successfully bound the posted form results to the typed model array in the controller action, however cannot seem to successfully reverse the effect and bind an existing model to the radio buttons while preserving their selected or unselected state. My model contains a property called "AnswerValue"

Is PowerShell a strongly-typed language?

别等时光非礼了梦想. 提交于 2019-12-21 03:34:30
问题 PowerShell is definitely in the category of dynamic languages, but would it be considered strongly typed? 回答1: There is a certain amount of confusion around the terminlogy. This article explains a useful taxonomy of type systems. PowerShell is dynamically, implicit typed: > $x=100 > $x=dir No type errors - a variable can change its type at runtime. This is like Python, Perl, JavaScript but different from C++, Java, C#, etc. However: > [int]$x = 100 > $x = dir Cannot convert "scripts-2.5" to

JSON deserialization to inherited types

偶尔善良 提交于 2019-12-20 18:06:39
问题 I have a data table in my database where I store various settings. Since they are of any type (even complex object graphs) I decided to store their values as serialized JSON strings. Let's say that I serialized a List<ItemBase> . Serialized string looks just fine. But the problem is that list items are of various types that are inherited from ItemBase (which may as well be abstract for what I care). Question Which (de)serialization class/library should I use so my JSON strings will be