Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I want use attributes in C# code which will work in my project which uses Mono.
It is possible to get class attributes from Mono runtime? And how, if it is possible?
A little explanation:
This is my class with attribute:
[SomeAttribute]
public class SomeClass { /* ... */ }
And somewhere in my C++ code I start Mono and load assembly with this class.
In C++ code I want to discover attributes of this SomeClass and perform some actions. So how can I do this? Can Mono tell what attributes used in this class?
It's going to be difficult to do this from the C++ side, so what you probably want to do is get the attributes as normal from within your C# class:
typeof(SomeType).GetAttributes()
And then call a function from your C++ code to actually access that information.
Using mono to call C# from C/C++
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Other than the fact that the compiler automatically generates certain functions for Data Class, what is the fundamental difference between them?
In Kotlin, classes declared with the data class keywords simply get some extra methods generated:
equals
hashcode
toString
copy
componentX
Declaring a regular class and defining these methods manually yields exactly the same thing. There is no other difference at bytecode level.
You do however have some extra limitations (no non-property constructor arguments, limitations on inheritance...), but these are just compile-time limitations so that the generated methods behave in a predictable/non surprising way.
The official doc covers everything in detail about them.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I want to understand the concept behind this Kotlin intent. What does Activity::class.java
mean in Kotlin ?
Kotlin is designed to be interoperable with Java. Pretty much all Java code can be called from Kotlin and vice versa without any issues.
What does Activity::class.java ?
Consider this expression val c = MyClass::class, In it the reference is a value of type KClass.
To obtain a Java class reference, we need to use the .java property on a KClass instance.
If you execute below code
var ktString = String::class
println(ktString)
var javaString = String::class.java
println(javaString)
Output will be
class kotlin.String
class java.lang.String
.java helps to get mapped type between Java and Kotlin at runtime. Please refer Kotlin Docs for list of mapped types.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Extension Methods are actually static methods. Does Asp.net core encourage to use static methods?
The framework uses extension methods to extend functionality. It allows for a modular system where components are registered using extension methods on low-level ASP.NET Core types. They are mainly used to configure application startup.
Sometimes utility methods for certain types are implemented as extension methods as well, rather than begin implemented in the type itself. This keeps the types clean and allows you to 'hide' advanced methods in a separate namespace.
ASP.NET Core actually discourages usage of statics by utilizing dependency injection as a first-class citizen. For example, there is no static HttpContext.Current anymore. Instead, you can get a hold of the current HTTP context by injecting IHttpContextAccessor into your services.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I am fairly new to Objective C and wonder if most people remove or don't remove unused methods. For example, when I create a UIViewController, there are stub methods that I often don't use, and I want to remove them.
You can remove them if you'd like. However, if you leave them in, make sure a call to super is performed in each method so that you don't lose the default implementation. This means you want your empty (for now) method to extend, not override, the functionality of that same method in parent class.
Edit: Having a method implementation that does nothing other than call the same method on super is equivalent to removing the method all together. Super will then be called by default.
I remove them along with all dead code. They just clutter the working code and reduce readability.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I've seen impl used as namespaces and as a class suffix in a number of different .net and Java libraries. I just want to know what it means and why it is used.
It stands for Implementation.
It's a Java convention.
Often in java (particularly J2EE) you will get an object from some factory, and then use it.
That object's type is often given to you as an interface, so that you don't need to know the actual class, just its methods.
An impl class is usually a class that implements the behaviour described by one of these interfaces.
It's short for "implementation". Generally it's used when the parent package contains abstract classes, interfaces, and perhaps some factory classes which are the main point of access, and then the impl package contains various concrete implementations of those abstract classes and interfaces.